Skip to content

Commit 2df4bd3

Browse files
libbson fuzzer for OSS-Fuzz integration. (#706)
1 parent 65dc45e commit 2df4bd3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/libbson/fuzz/fuzz_test_libbson.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <stdint.h>
4+
#include <bson/bson.h>
5+
6+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
7+
char *nt = malloc(size+1);
8+
memcpy(nt, data, size);
9+
nt[size] = '\0';
10+
bson_error_t error;
11+
12+
bson_t b;
13+
if (bson_init_from_json(&b, nt, -1, &error)) {
14+
bson_destroy(&b);
15+
}
16+
17+
free(nt);
18+
return 0;
19+
}

0 commit comments

Comments
 (0)