From: Kamalesh Babulal Date: Thu, 28 Jul 2022 19:32:05 +0000 (-0600) Subject: api.c: check the bytes read in cgroup_register_unchanged_process() X-Git-Tag: v3.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d266da61515bb47b889a93229302e545da207fe;p=thirdparty%2Flibcgroup.git api.c: check the bytes read in cgroup_register_unchanged_process() Fix ignoring the number of bytes read, warning reported by Coverity tool: CID 258288 (#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 cgroup_register_unchanged_process(), the number of byte read/written using read()/write() are ignored but coverity it warns about the read() only, let's fix it. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 4f1059b5..a5a98dc7 100644 --- a/src/api.c +++ b/src/api.c @@ -5440,6 +5440,7 @@ int cgroup_register_unchanged_process(pid_t pid, int flags) { char buff[sizeof(CGRULE_SUCCESS_STORE_PID)]; struct sockaddr_un addr; + size_t ret_len; int ret = 1; int sk; @@ -5463,7 +5464,8 @@ int cgroup_register_unchanged_process(pid_t pid, int flags) if (write(sk, &flags, sizeof(flags)) < 0) goto close; - if (read(sk, buff, sizeof(buff)) < 0) + ret_len = read(sk, buff, sizeof(buff)); + if (ret_len != sizeof(buff)) goto close; if (strncmp(buff, CGRULE_SUCCESS_STORE_PID, sizeof(buff)))