MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

extern/re2/re2/fuzzing/re2_fuzzer.cc:136–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134
135// Entry point for libFuzzer.
136extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
137 // An input larger than 4 KiB probably isn't interesting. (This limit
138 // allows for fdp.ConsumeRandomLengthString()'s backslash behaviour.)
139 if (size == 0 || size > 4096)
140 return 0;
141
142 FuzzedDataProvider fdp(data, size);
143
144 // The convention here is that fdp.ConsumeBool() returning false sets
145 // the default value whereas returning true sets the alternate value:
146 // most options default to false and so can be set directly; encoding
147 // defaults to UTF-8; case_sensitive defaults to true. We do NOT want
148 // to log errors. max_mem is 64 MiB because we can afford to use more
149 // RAM in exchange for (hopefully) faster fuzzing.
150 RE2::Options options;
151 options.set_encoding(fdp.ConsumeBool() ? RE2::Options::EncodingLatin1
152 : RE2::Options::EncodingUTF8);
153 options.set_posix_syntax(fdp.ConsumeBool());
154 options.set_longest_match(fdp.ConsumeBool());
155 options.set_log_errors(false);
156 options.set_max_mem(64 << 20);
157 options.set_literal(fdp.ConsumeBool());
158 options.set_never_nl(fdp.ConsumeBool());
159 options.set_dot_nl(fdp.ConsumeBool());
160 options.set_never_capture(fdp.ConsumeBool());
161 options.set_case_sensitive(!fdp.ConsumeBool());
162 options.set_perl_classes(fdp.ConsumeBool());
163 options.set_word_boundary(fdp.ConsumeBool());
164 options.set_one_line(fdp.ConsumeBool());
165
166 std::string pattern = fdp.ConsumeRandomLengthString(999);
167 std::string text = fdp.ConsumeRandomLengthString(999);
168
169 TestOneInput(pattern, options, text);
170 return 0;
171}

Callers 1

mainFunction · 0.85

Calls 15

TestOneInputFunction · 0.85
set_encodingMethod · 0.80
ConsumeBoolMethod · 0.80
set_posix_syntaxMethod · 0.80
set_longest_matchMethod · 0.80
set_log_errorsMethod · 0.80
set_max_memMethod · 0.80
set_literalMethod · 0.80
set_never_nlMethod · 0.80
set_dot_nlMethod · 0.80
set_never_captureMethod · 0.80
set_case_sensitiveMethod · 0.80

Tested by

no test coverage detected