Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added a first fuzzer for integration with OSS-Fuzz. #2255

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/jq_fuzz_parse.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "jv.h"

int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
// Creat null-terminated string
char *null_terminated = (char *)malloc(size + 1);
memcpy(null_terminated, (char *)data, size);
null_terminated[size] = '\0';

// Fuzzer entrypoint
jv res = jv_parse(null_terminated);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, we do have a jv_parse_sized() so you don't have to add a NUL terminator.

jv_free(res);

// Free the null-terminated string
free(null_terminated);

return 0;
}