From: Sebastian Harl Date: Tue, 11 Dec 2012 08:06:57 +0000 (+0100) Subject: utils unixsock: Fixed EOF handling in recv(). X-Git-Tag: sysdb-0.1.0~462 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f569dc6128ec3660ee829af8b84d0342a2e09536;p=sysdb.git utils unixsock: Fixed EOF handling in recv(). --- 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';