File tree 5 files changed +41
-2
lines changed
5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 17
17
# fuzzers that change behaviour with SIMDJSON_FORCE_IMPLEMENTATION
18
18
defaultimplfuzzers : atpointer dump dump_raw_tape element minify parser print_json
19
19
# fuzzers that loop over the implementations themselves, or don't need to switch.
20
- implfuzzers : implementations minifyimpl ondemand padded utf8
20
+ implfuzzers : implementations minifyimpl ndjson ondemand padded utf8
21
21
implementations : haswell westmere fallback
22
22
UBSAN_OPTIONS : halt_on_error=1
23
23
MAXLEN : -max_len=4000
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ if(ENABLE_FUZZING)
57
57
implement_fuzzer(fuzz_implementations) # parses and serializes again, compares across implementations
58
58
implement_fuzzer(fuzz_minify) # minify *with* parsing
59
59
implement_fuzzer(fuzz_minifyimpl) # minify *without* parsing, plus compare implementations
60
+ implement_fuzzer(fuzz_ndjson) # the ndjson api
60
61
implement_fuzzer(fuzz_ondemand)
61
62
implement_fuzzer(fuzz_padded)
62
63
implement_fuzzer(fuzz_parser)
Original file line number Diff line number Diff line change @@ -105,6 +105,14 @@ struct FuzzData {
105
105
return {};
106
106
}
107
107
108
+ // consumes the rest of the data as a string view
109
+ std::string_view remainder_as_stringview () {
110
+ std::string_view ret{chardata (),Size };
111
+ Data+=Size ;
112
+ Size =0 ;
113
+ return ret;
114
+ }
115
+
108
116
// split the remainder of the data into string views,
109
117
std::vector<std::string_view> splitIntoStrings () {
110
118
std::vector<std::string_view> ret;
Original file line number Diff line number Diff line change
1
+ #include " simdjson.h"
2
+ #include < cstddef>
3
+ #include < cstdint>
4
+ #include < string>
5
+
6
+ #include " FuzzUtils.h"
7
+ #include " NullBuffer.h"
8
+
9
+ extern " C" int LLVMFuzzerTestOneInput (const uint8_t *Data, size_t Size ) {
10
+ FuzzData fd (Data, Size );
11
+ const auto batch_size=static_cast <size_t >(fd.getInt <0 ,1000 >());
12
+ const auto json=simdjson::padded_string{fd.remainder_as_stringview ()};
13
+ simdjson::dom::parser parser;
14
+ #if SIMDJSON_EXCEPTIONS
15
+ try {
16
+ #endif
17
+ simdjson::dom::document_stream docs;
18
+ if (parser.parse_many (json,batch_size).get (docs)) {
19
+ return 0 ;
20
+ }
21
+
22
+ size_t bool_count=0 ;
23
+ for (auto doc : docs) {
24
+ bool_count+=doc.is_bool ();
25
+ }
26
+ #if SIMDJSON_EXCEPTIONS
27
+ } catch (...) {
28
+ }
29
+ #endif
30
+ return 0 ;
31
+ }
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ cmake .. \
30
30
-DENABLE_FUZZING=On \
31
31
-DSIMDJSON_COMPETITION=Off \
32
32
-DSIMDJSON_FUZZ_LINKMAIN=Off \
33
- -DSIMDJSON_GIT=Off \
34
33
-DSIMDJSON_GOOGLE_BENCHMARKS=Off \
35
34
-DSIMDJSON_DISABLE_DEPRECATED_API=On \
36
35
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
You can’t perform that action at this time.
0 commit comments