From: Kamalesh Babulal Date: Wed, 10 Aug 2022 17:10:54 +0000 (-0600) Subject: daemon/cgrulesengd: check the bytes read in cgre_receive_unix_domain_msg() X-Git-Tag: v2.0.3~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c518abe761560c57b15541d85365602e0fce27d8;p=thirdparty%2Flibcgroup.git daemon/cgrulesengd: check the bytes read in cgre_receive_unix_domain_msg() Fix ignoring the number of bytes read, warning reported by Coverity tool: CID 258286 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN). check_return: read(int, void *, size_t) returns the number of bytes read, but it is ignored. In cgre_receive_unix_domain_msg(), the number of bytes read() is ignored, while reading from the flag value of the pid. Coverity warns on not checking the number of bytes read, fix it. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka (cherry picked from commit ed283eab173addd3b5c2dd666de8f3086125e106) --- diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c index d76f13fa..f597d25e 100644 --- a/src/daemon/cgrulesengd.c +++ b/src/daemon/cgrulesengd.c @@ -618,7 +618,8 @@ static void cgre_receive_unix_domain_msg(int sk_unix) strerror(errno)); return; } - if (read(fd_client, &pid, sizeof(pid)) < 0) { + ret_len = read(fd_client, &pid, sizeof(pid)); + if (ret_len != sizeof(pid)) { flog(LOG_WARNING, "Warning: 'read' command error: %s\n", strerror(errno)); goto close;