]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: fix coverity out of bounds read warning
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 25 May 2022 13:40:10 +0000 (07:40 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 25 May 2022 13:40:20 +0000 (07:40 -0600)
commit5a5e918f08b73c5aa6c7ae2122ac9b066e51cead
tree854dd3aefe4b6db9f1c883638c8a732847462f72
parent17b3a2d612cc8747dcf916b0cf29775cc88f4a23
api.c: fix coverity out of bounds read warning

Fix out of bounds read, reported by Coverity tool:

CID 1412156 (#1 of 1): Out-of-bounds read (OVERRUN).
overrun-local: Overrunning array cgroup_strerror_codes of 30 8-byte
elements at element index 49999 (byte offset 399999) using index
code % ECGROUPNOTCOMPILED (which evaluates to 49999).

Reproducer:
-----------
$ cat cgrp-strerr.c

int main(void)
{
        int err = ECGNONEMPTY;

        fprintf(stderr, "%s\n", cgroup_strerror(err));

        return 0;
}

without the patch:
-----------------
$ ./cgrp-stderr
(null)

with the patch:
---------------
$ ./cgrp-stderr
Failed to remove a non-empty group

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c