Skip to content

Commit

Permalink
fix to run fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Jan 15, 2025
1 parent 78184d9 commit 709b8dd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ if(ENABLE_FUZZING)

foreach(target ${FUZZ_TARGETS})
add_executable(fuzz-${target} ${CMAKE_CURRENT_SOURCE_DIR}/fuzz/${target}.cpp)
target_link_libraries(fuzz-${target} PRIVATE app_lib)
target_link_libraries(fuzz-${target} PRIVATE
app_lib
rslib)
target_link_options(fuzz-${target} PRIVATE "-fsanitize=fuzzer")
endforeach()
else()
Expand Down
5 changes: 0 additions & 5 deletions fuzz/parser_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
uint8_t num_items;
rc = parser_getNumItems(&ctx, &num_items);
if (rc != parser_ok) {
fprintf(stderr, "error in parser_getNumItems: %s\n", parser_getErrorDescription(rc));
assert(false);
}

(void)fprintf(stderr, "----------------------------------------------\n");

for (uint8_t i = 0; i < num_items; i += 1) {
uint8_t page_idx = 0;
uint8_t page_count = 1;
while (page_idx < page_count) {
rc = parser_getItem(&ctx, i, PARSER_KEY, sizeof(PARSER_KEY), PARSER_VALUE, sizeof(PARSER_VALUE), page_idx,
&page_count);

// (void)fprintf(stderr, "%s = %s\n", PARSER_KEY, PARSER_VALUE);

if (rc != parser_ok) {
(void)fprintf(stderr, "error getting item %u at page index %u: %s\n", (unsigned)i, (unsigned)page_idx,
parser_getErrorDescription(rc));
Expand Down
2 changes: 1 addition & 1 deletion fuzz/run-fuzz-crashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

artifact_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}-artifacts')
corpus_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}')
fuzz_path = os.path.join(f'build/bin/fuzz-{fuzzer}')
fuzz_path = os.path.join(f'build/fuzz-{fuzzer}')

os.makedirs(artifact_dir, exist_ok=True)
os.makedirs(corpus_dir, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion fuzz/run-fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

artifact_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}-artifacts')
corpus_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}')
fuzz_path = os.path.join(f'build/bin/fuzz-{fuzzer}')
fuzz_path = os.path.join(f'build/fuzz-{fuzzer}')

os.makedirs(artifact_dir, exist_ok=True)
os.makedirs(corpus_dir, exist_ok=True)
Expand Down

0 comments on commit 709b8dd

Please sign in to comment.