libubox/tests
Juraj Vijtiuk 43a103ff17 blobmsg: blobmsg_parse and blobmsg_parse_array oob read fixes
Fix out of bounds read in blobmsg_parse and blobmsg_check_name. The
out of bounds read happens because blob_attr and blobmsg_hdr have
flexible array members, whose size is 0 in the corresponding sizeofs.
For example the __blob_for_each_attr macro checks whether rem >=
sizeof(struct blob_attr). However, what LibFuzzer discovered was,
if the input data was only 4 bytes, the data would be casted to blob_attr,
and later on blob_data(attr) would be called even though attr->data was empty.
The same issue could appear with data larger than 4 bytes, where data
wasn't empty, but contained only the start of the blobmsg_hdr struct,
and blobmsg_hdr name was empty. The bugs were discovered by fuzzing
blobmsg_parse and blobmsg_array_parse with LibFuzzer.

CC: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>
[refactored some checks, added fuzz inputs, adjusted unit test results]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-01-20 16:54:10 +01:00
..
cram blobmsg: blobmsg_parse and blobmsg_parse_array oob read fixes 2020-01-20 16:54:10 +01:00
fuzz blobmsg: blobmsg_parse and blobmsg_parse_array oob read fixes 2020-01-20 16:54:10 +01:00
shunit2 tests: include json script shunit2 based testing 2020-01-12 19:17:17 +01:00
CMakeLists.txt tests: include json script shunit2 based testing 2020-01-12 19:17:17 +01:00
test-avl.c add cram based unit tests 2019-11-24 13:26:58 +01:00
test-b64.c tests: prefer dynamically allocated buffers 2020-01-20 16:54:10 +01:00
test-b64_decode.c base64: fix possible null pointer dereference 2019-11-24 13:26:58 +01:00
test-b64_encode.c base64: fix possible null pointer dereference 2019-11-24 13:26:58 +01:00
test-blob-parse.c tests: prefer dynamically allocated buffers 2020-01-20 16:54:10 +01:00
test-blobmsg-parse.c tests: prefer dynamically allocated buffers 2020-01-20 16:54:10 +01:00
test-blobmsg-procd-instance.c tests: prefer dynamically allocated buffers 2020-01-20 16:54:10 +01:00
test-blobmsg.c blobmsg_json: prefer snprintf usage 2020-01-20 16:54:10 +01:00
test-json-script.c add cram based unit tests 2019-11-24 13:26:58 +01:00
test-list.c add cram based unit tests 2019-11-24 13:26:58 +01:00
test-runqueue.c add cram based unit tests 2019-11-24 13:26:58 +01:00