summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike McTernan <mikemcternan@google.com>2022-11-30 14:23:35 +0000
committerMike McTernan <mikemcternan@google.com>2022-12-01 11:59:35 +0000
commit6d838ebf29c7044596c5cb0936693c05e9a7ae10 (patch)
tree627bfbc2d3bde492b9f18bc39186f56c72c7d7b8 /tests
parent67ce20e01a858c995bf0b3cb8a728b6e55b0b6ff (diff)
downloadlibufdt-6d838ebf29c7044596c5cb0936693c05e9a7ae10.tar.gz
libufdt: Fix possible null pointer access if test program is fed bad input.
Test: mma libufdt_fuzzer && system/libufdt/tests/run_tests.sh Change-Id: I20bb070da9192da0795f1bfc7d21d881780429f4
Diffstat (limited to 'tests')
-rw-r--r--tests/src/ufdt_overlay_test_app.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/src/ufdt_overlay_test_app.c b/tests/src/ufdt_overlay_test_app.c
index d7c4437..e73158b 100644
--- a/tests/src/ufdt_overlay_test_app.c
+++ b/tests/src/ufdt_overlay_test_app.c
@@ -54,6 +54,11 @@ int apply_overlay_files(const char *out_filename, const char *base_filename,
new_blob = ufdt_apply_overlay(blob, blob_len, overlay_buf, overlay_len);
clock_t end = clock();
+ if (!new_blob) {
+ fprintf(stderr, "ufdt_apply_overlay() returned null: bad input?\n");
+ goto end;
+ }
+
if (write_fdt_to_file(out_filename, new_blob) != 0) {
fprintf(stderr, "Write file error: %s\n", out_filename);
goto end;