Project

General

Profile

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

S3_2, S3_1 - 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 == NULL) {
log_error("socket %d: failed to fdopen()", sock);
return NULL;
}
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];
(2-2/2)