]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
daemon/cgrulesengd: check the bytes read in cgre_receive_unix_domain_msg()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 10 Aug 2022 17:08:26 +0000 (11:08 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 10 Aug 2022 17:08:30 +0000 (11:08 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/daemon/cgrulesengd.c

index 7c514122877c524a97dff6bc1ee27e0d27328768..51988de50b6d95e8d210b09fc8fb0b7f803bf348 100644 (file)
@@ -619,7 +619,8 @@ static void cgre_receive_unix_domain_msg(int sk_unix)
                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;
        }