]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: check for invalid error code in cgroup_strerror()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 27 Jul 2022 19:15:04 +0000 (13:15 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 27 Jul 2022 19:15:06 +0000 (13:15 -0600)
commit728c6f8fb0f760d786156153b74de9010863584c
tree37e3c1318c8db885fe7598ffa36ffe4b51445cef
parente5031f8b5472a41c53f517188dff7adfa1b04f2c
api.c: check for invalid error code in cgroup_strerror()

Fix array overflow warning, reported by the Coverity tool:

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

there are chances of users passing error codes, resulting in crossing
the upper bound of the cgroup_strerror_codes[], fix it by introducing
bound checks.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 37fab4e36b3785698fcc8af14e624cf1e182c183)
src/api.c