From 3545ccee06dde5d357ff4c9811939af1e1c0622e Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 28 Jul 2020 10:19:30 -0400 Subject: [PATCH] Fix: common: improper use of negative return MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit From Coverity: CID 1431053 (#1 of 2): Improper use of negative value (NEGATIVE_RETURNS) 5. negative_returns: fd_count is passed to a parameter that cannot be negative. Solution ======== Check return value for fd_count and goto error if negative. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Ibdb2f065f0ebe51efae9125630a17730386395ac --- src/common/unix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/unix.c b/src/common/unix.c index 502002425..205334325 100644 --- a/src/common/unix.c +++ b/src/common/unix.c @@ -453,6 +453,11 @@ ssize_t _lttcomm_send_payload_view_fds_unix_sock(int sock, lttng_dynamic_array_init(&raw_fds, sizeof(int), NULL); + if (fd_count < 0) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + /* * Prepare a contiguous array of file descriptors to send them. * -- 2.34.1