From: David Goulet Date: Thu, 20 Dec 2012 01:56:04 +0000 (-0500) Subject: Fix: bad check of accept() return value X-Git-Tag: v2.1.0~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=534d2592c0566f7c07cd9e9f9385781a65566e16;p=lttng-tools.git Fix: bad check of accept() return value Also fix a missing ret = -1 assignment. Although, the chances are unlikely to hit a positive ret value that does not match the structure size, better safe than sorry. Signed-off-by: David Goulet --- diff --git a/src/common/consumer.c b/src/common/consumer.c index 63c98350a..1045bfb46 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1334,6 +1334,12 @@ static int write_relayd_metadata_id(int fd, PERROR("write metadata stream id"); } DBG3("Consumer failed to write relayd metadata id (errno: %d)", errno); + /* + * Set ret to a negative value because if ret != sizeof(hdr), we don't + * handle writting the missing part so report that as an error and + * don't lie to the caller. + */ + ret = -1; goto end; } DBG("Metadata stream id %" PRIu64 " with padding %lu written before data", @@ -2597,7 +2603,7 @@ void *consumer_thread_sessiond_poll(void *data) /* Blocking call, waiting for transmission */ sock = lttcomm_accept_unix_sock(client_socket); - if (sock <= 0) { + if (sock < 0) { WARN("On accept"); goto end; }