File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 66#include " ada.cpp"
77#include " ada.h"
88
9- extern " C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) {
9+ std::string bytesToAlphanumeric (const std::string& source) {
10+ static const char alphanumeric[] =
11+ " abcdefghijklmnopqrstuvwxyz"
12+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13+ " 0123456789" ;
14+
15+ std::string result;
16+ result.reserve (source.size ());
17+
18+ for (char byte : source) {
19+ int index = static_cast <unsigned char >(byte) % (sizeof (alphanumeric) - 1 );
20+ result.push_back (alphanumeric[index]);
21+ }
22+
23+ return result;
24+ }
25+
26+ extern " C" int LLVMFuzzerTestOneInput (const uint8_t * data, size_t size) {
1027 FuzzedDataProvider fdp (data, size);
11- std::string source = fdp.ConsumeRandomLengthString (50 );
12- std::string base_source = fdp.ConsumeRandomLengthString (50 );
28+ // We do not want to trigger arbitrary regex matching.
29+ std::string source =
30+ " /" + bytesToAlphanumeric (fdp.ConsumeRandomLengthString (50 )) + " /" +
31+ bytesToAlphanumeric (fdp.ConsumeRandomLengthString (50 ));
32+ std::string base_source =
33+ " /" + bytesToAlphanumeric (fdp.ConsumeRandomLengthString (50 )) + " /" +
34+ bytesToAlphanumeric (fdp.ConsumeRandomLengthString (50 ));
1335
1436 // Without base or options
1537 auto result = ada::parse_url_pattern (source, nullptr , nullptr );
You can’t perform that action at this time.
0 commit comments