From 6c8f6390bc6235a6be449585acf5fd34997f5127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 5 Dec 2024 20:30:05 +0100 Subject: [PATCH] libselinux/fuzz: update for lookup_all() change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 89dd0b23 ("libselinux: avoid memory allocation in common file label lookup") added an additional parameter to lookup_all() for an optional buffer the return value might be placed into. Update the fuzzing related code accordingly. Fixes: 89dd0b23 ("libselinux: avoid memory allocation in common file label lookup") Signed-off-by: Christian Göttsche Acked-by: James Carter --- libselinux/fuzz/selabel_file_compiled-fuzzer.c | 2 +- libselinux/fuzz/selabel_file_text-fuzzer.c | 2 +- libselinux/src/label_file.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libselinux/fuzz/selabel_file_compiled-fuzzer.c b/libselinux/fuzz/selabel_file_compiled-fuzzer.c index cf0710ad1..d1249a763 100644 --- a/libselinux/fuzz/selabel_file_compiled-fuzzer.c +++ b/libselinux/fuzz/selabel_file_compiled-fuzzer.c @@ -232,7 +232,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) assert(cmp(&rec, &rec) == SELABEL_EQUAL); errno = 0; - result = lookup_all(&rec, key, mode, partial, find_all); + result = lookup_all(&rec, key, mode, partial, find_all, NULL); if (!result) assert(errno != 0); diff --git a/libselinux/fuzz/selabel_file_text-fuzzer.c b/libselinux/fuzz/selabel_file_text-fuzzer.c index 5d851de14..ed67ea25a 100644 --- a/libselinux/fuzz/selabel_file_text-fuzzer.c +++ b/libselinux/fuzz/selabel_file_text-fuzzer.c @@ -178,7 +178,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) assert(cmp(&rec, &rec) == SELABEL_EQUAL); errno = 0; - result = lookup_all(&rec, key, mode, partial, find_all); + result = lookup_all(&rec, key, mode, partial, find_all, NULL); if (!result) assert(errno != 0); diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h index c7fe3a481..562c3da60 100644 --- a/libselinux/src/label_file.h +++ b/libselinux/src/label_file.h @@ -63,7 +63,7 @@ struct lookup_result { extern int load_mmap(FILE *fp, const size_t len, struct selabel_handle *rec, const char *path); extern int process_text_file(FILE *fp, const char *prefix, struct selabel_handle *rec, const char *path); extern void free_lookup_result(struct lookup_result *result); -extern struct lookup_result *lookup_all(struct selabel_handle *rec, const char *key, int type, bool partial, bool find_all); +extern struct lookup_result *lookup_all(struct selabel_handle *rec, const char *key, int type, bool partial, bool find_all, struct lookup_result *buf); extern enum selabel_cmp_result cmp(const struct selabel_handle *h1, const struct selabel_handle *h2); #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */