summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pierre-Clément Tosi <ptosi@google.com> 2022-08-01 10:37:12 +0100
committer Pierre-Clément Tosi <ptosi@google.com> 2022-08-01 10:39:57 +0100
commit70fd2e82371d7fa89249124ce6ec533cc8c3f05d (patch)
tree23fc9475c0d70508cbd140d578c2c335ebdfbd69
parentc0a4830d8dc889eda299524f9dad159c0fc70745 (diff)
ANDROID: fuzz: Check for NULL property during walk
When fdt_get_property_by_offset() fails, it returns NULL so prevent the fuzzer from dereferencing the pointer, in that case. Bug: 240841657 Test: SANITIZE_HOST=address m libfdt_fuzzer Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Change-Id: Idcd187993fce0140038b61589a183b16d822004b
-rw-r--r--fuzzing/libfdt_fuzzer.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fuzzing/libfdt_fuzzer.c b/fuzzing/libfdt_fuzzer.c
index b433bbc..f89f1b4 100644
--- a/fuzzing/libfdt_fuzzer.c
+++ b/fuzzing/libfdt_fuzzer.c
@@ -62,6 +62,8 @@ static void walk_node_properties(const void *device_tree, int node) {
fdt_for_each_property_offset(property, device_tree, node) {
const struct fdt_property *prop = fdt_get_property_by_offset(device_tree,
property, &len);
+ if (!prop)
+ continue;
check_mem(prop->data, fdt32_to_cpu(prop->len));
}
}