Project

General

Profile

Feature #851 » 0028-fc_querysocket-Handle-fdopen-errors.patch

main - Marko Lindqvist, 09/13/2024 06:14 PM

View differences:

utility/netintf.c
}
/*********************************************************************//**
Writes buf to socket and returns the response in an fz_FILE.
Writes buf to socket and returns the response in a fz_FILE.
Use only on blocking sockets.
*************************************************************************/
fz_FILE *fc_querysocket(int sock, void *buf, size_t size)
......
#ifdef HAVE_FDOPEN
fp = fdopen(sock, "r+b");
if (fp == nullptr) {
log_error("socket %d: failed to fdopen()", sock);
return nullptr;
}
if (fwrite(buf, 1, size, fp) != size) {
log_error("socket %d: write error", sock);
}
fflush(fp);
/* We don't use fc_closesocket() on sock here since when fp is closed
* sock will also be closed. fdopen doesn't dup the socket descriptor. */
/* We don't use fc_closesocket() on sock here since when fp is closed,
* sock will also be closed. fdopen() doesn't dup the socket descriptor. */
#else /* HAVE_FDOPEN */
{
char tmp[4096];
(1-1/2)