From f569dc6128ec3660ee829af8b84d0342a2e09536 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 11 Dec 2012 09:06:57 +0100 Subject: [PATCH 1/1] utils unixsock: Fixed EOF handling in recv(). --- src/utils/unixsock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/unixsock.c b/src/utils/unixsock.c index 1be17b9..70fd273 100644 --- a/src/utils/unixsock.c +++ b/src/utils/unixsock.c @@ -144,10 +144,12 @@ sc_unixsock_client_recv(sc_unixsock_client_t *client, char *buffer, size_t bufle return NULL; buffer = fgets(buffer, (int)buflen - 1, client->fh); - if ((! buffer) && (! feof(client->fh))) { - char errbuf[1024]; - fprintf(stderr, "unixsock: Failed to read from socket (%s): %s\n", - client->path, sc_strerror(errno, errbuf, sizeof(errbuf))); + if (! buffer) { + if (! feof(client->fh)) { + char errbuf[1024]; + fprintf(stderr, "unixsock: Failed to read from socket (%s): %s\n", + client->path, sc_strerror(errno, errbuf, sizeof(errbuf))); + } return buffer; } buffer[buflen - 1] = '\0'; -- 2.30.2