Skip to content

Commit

Permalink
libselinux/fuzz: update for lookup_all() change
Browse files Browse the repository at this point in the history
Commit 89dd0b2 ("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: 89dd0b2 ("libselinux: avoid memory allocation in common file label lookup")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
  • Loading branch information
cgzones authored and jwcart2 committed Dec 17, 2024
1 parent b234b71 commit 6c8f639
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libselinux/fuzz/selabel_file_compiled-fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libselinux/fuzz/selabel_file_text-fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libselinux/src/label_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down

0 comments on commit 6c8f639

Please sign in to comment.