Skip to content

Commit 8b883d1

Browse files
authored
OSS-Fuzz: Add new fuzzer targets unmarshal (#1762)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
1 parent ceb5697 commit 8b883d1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/fuzzers/fuzz_unmarshal.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdint.h>
2+
#include <janet.h>
3+
4+
/* Disable leak sanitizer */
5+
int __lsan_is_turned_off(void) { return 1; }
6+
7+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
8+
9+
/* init Janet */
10+
janet_init();
11+
12+
/* fuzz the binary unmarshal (deserialization) path in src/core/marsh.c */
13+
JanetTable *reg = janet_env_lookup(janet_core_env(NULL));
14+
JanetTryState tstate;
15+
if (janet_try(&tstate) == JANET_SIGNAL_OK) {
16+
const uint8_t *next = NULL;
17+
janet_unmarshal(data, size, 0, reg, &next);
18+
}
19+
janet_restore(&tstate);
20+
21+
/* cleanup Janet */
22+
janet_deinit();
23+
24+
return 0;
25+
}

0 commit comments

Comments
 (0)