Skip to content

Commit

Permalink
Add fuzzer for OSS-Fuzz integration
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <david@adalogics.com>
  • Loading branch information
DavidKorczynski authored and andikleen committed Mar 15, 2023
1 parent 6587ed2 commit 0cb865a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Numaqtl fuzzing

OSS-Fuzz fuzzing suite. Fuzzers here are meant to run by way of OSS-Fuzz and
will be build and executed continuously.
28 changes: 28 additions & 0 deletions fuzz/fuzz_parse_str.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdint.h>
#include <stdlib.h>
#include "numa.h"


int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct bitmask *mask = NULL;

char *fuzz_str1 = malloc(size+1);
memcpy(fuzz_str1, data, size);
fuzz_str1[size] = '\0';

mask = numa_parse_nodestring(fuzz_str1);
if (mask != NULL) {
numa_bitmask_free(mask);
}

// NULLify the mask variable before we use it again.
mask = NULL;
mask = numa_parse_cpustring(fuzz_str1);
if (mask != NULL) {
numa_node_to_cpus_v2(0, mask);
numa_bitmask_free(mask);
}

free(fuzz_str1);
return 0;
}

0 comments on commit 0cb865a

Please sign in to comment.