The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"
More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/16
Fix the warning by adding an additional "EOF" check for the ret value
from fscanf() in the cgroup_get_current_controller_path()
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ret = fscanf(pid_cgroup_fd, "%*[^\n]\n");
if (ret == 0)
continue;
+
+ if (ret == EOF) {
+ last_errno = errno;
+ ret = ECGEOF;
+ goto done;
+ }
}
cgroup_warn("read failed for pid_cgroup_fd ret %d\n", ret);