]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgsnapshot: fix out-of-bounds write in parse_controllers()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 27 Jul 2022 19:28:04 +0000 (13:28 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 27 Jul 2022 19:28:07 +0000 (13:28 -0600)
commitde951069e925a697a047c6327a8578ef6b5d2353
treeaff1dd183382781a405da94dc136b396f455a9b2
parent37fab4e36b3785698fcc8af14e624cf1e182c183
tools/cgsnapshot: fix out-of-bounds write in parse_controllers()

Fix Out-of-bounds write warning, reported by Coverity tool:

CID 258289 (#2 of 2): Out-of-bounds write (OVERRUN)16. overrun-local:
Overrunning array controllers of 100 4096-byte elements at element index
100 (byte offset 413695) using index max (which evaluates to 100).

there are chances, that the index variable max dereferences controller
array might be over the array size of 100. Add upper bound checks
to index variable max, so that it doesn't overrun the controller array.

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