]> git.ipfire.org Git - thirdparty/json-c.git/commit
Validate size arguments in arraylist functions. 660/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Aug 2020 10:06:15 +0000 (12:06 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 24 Aug 2020 10:13:50 +0000 (12:13 +0200)
commit369e8477d25132e9eeefb89ae1dacb3c4a738652
tree2bbfe0a56b4679073c9bc84d8df43d29a4ff1977
parent2b439ea59857747067e8272011ad67303e0d4cf1
Validate size arguments in arraylist functions.

The array_list_new2 function, which is externally reachable through
json_object_new_array_ext, does not check if specified initial size
actually fits into memory on 32 bit architectures.

It also allows negative values, which could lead to an overflow on these
architectures as well. I have added test cases for these situations.

While at it, also protect array_list_shrink against too large
empty_slots argument. No test added because it takes a huge length
value, therefore a lot of items within the array, to overflow the
calculation. In theory this affects 64 bit sytems as well, but since the
arraylist API is not supposed to be used by external applications
according to its header file, the call is protected due to int
limitation of json_object_array_shrink.
arraylist.c
tests/test1.c