File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- all : fuzzer-html fuzzer-email fuzzer-httpclient fuzzer-json fuzzer-difflib fuzzer-csv fuzzer-decode fuzzer-ast fuzzer-tarfile fuzzer-tarfile-hypothesis fuzzer-zipfile fuzzer-zipfile-hypothesis fuzzer-re fuzzer-configparser fuzzer-tomllib fuzzer-plistlib fuzzer-xml fuzzer-zoneinfo
1+ all : fuzzer-html fuzzer-email fuzzer-httpclient fuzzer-json fuzzer-difflib fuzzer-csv fuzzer-decode fuzzer-ast fuzzer-tarfile fuzzer-tarfile-hypothesis fuzzer-zipfile fuzzer-zipfile-hypothesis fuzzer-re fuzzer-configparser fuzzer-tomllib fuzzer-plistlib fuzzer-xml fuzzer-zoneinfo fuzzer-locale
22
33PYTHON_CONFIG_PATH =$(CPYTHON_INSTALL_PATH ) /bin/python3-config
44CXXFLAGS += $(shell $(PYTHON_CONFIG_PATH ) --cflags)
5- LDFLAGS += -rdynamic $(shell $(PYTHON_CONFIG_PATH ) --ldflags --embed)
5+ LDFLAGS += -rdynamic $(shell $(PYTHON_CONFIG_PATH ) --ldflags --embed) $( CPYTHON_MODLIBS ) -Wl,--allow-multiple-definition
66
77fuzzer-html :
88 clang++ $(CXXFLAGS ) $(LIB_FUZZING_ENGINE ) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH=" \" html.py\" " -ldl $(LDFLAGS ) -o fuzzer-html
@@ -40,3 +40,6 @@ fuzzer-xml:
4040 clang++ $(CXXFLAGS ) $(LIB_FUZZING_ENGINE ) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH=" \" xml.py\" " -ldl $(LDFLAGS ) -o fuzzer-xml
4141fuzzer-zoneinfo :
4242 clang++ $(CXXFLAGS ) $(LIB_FUZZING_ENGINE ) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH=" \" zoneinfo.py\" " -ldl $(LDFLAGS ) -o fuzzer-zoneinfo
43+
44+ fuzzer-locale :
45+ clang++ $(CXXFLAGS ) $(LIB_FUZZING_ENGINE ) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH=" \" locale.py\" " -ldl $(LDFLAGS ) -o fuzzer-locale
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ email email.py
77html html.py
88httpclient httpclient.py
99json json.py
10+ locale locale.py
1011plistlib plist.py
1112re re.py
1213tarfile tarfile.py
Original file line number Diff line number Diff line change 1+ from fuzzeddataprovider import FuzzedDataProvider
2+ import locale
3+
4+ OP_STRXFRM = 0
5+ OP_STRCOLL = 1
6+
7+ # Fuzzes the _locale C module (Modules/_localemodule.c).
8+ # Exercises locale.strxfrm() for locale-aware string transformation
9+ # and locale.strcoll() for locale-aware string comparison, both with
10+ # fuzz-generated Unicode input.
11+ def FuzzerRunOne (FuzzerInput ):
12+ if len (FuzzerInput ) < 1 or len (FuzzerInput ) > 0x10000 :
13+ return
14+ fdp = FuzzedDataProvider (FuzzerInput )
15+ target = fdp .ConsumeIntInRange (OP_STRXFRM , OP_STRCOLL )
16+ n = fdp .ConsumeIntInRange (1 , min (fdp .remaining_bytes (), 10000 )) if fdp .remaining_bytes () > 0 else 0
17+ if n == 0 :
18+ return
19+ s = fdp .ConsumeUnicode (n )
20+ try :
21+ if target == OP_STRXFRM :
22+ locale .strxfrm (s )
23+ elif target == OP_STRCOLL :
24+ n2 = fdp .ConsumeIntInRange (1 , min (fdp .remaining_bytes (), 10000 )) if fdp .remaining_bytes () > 0 else 0
25+ s2 = fdp .ConsumeUnicode (n2 ) if n2 > 0 else ""
26+ locale .strcoll (s , s2 )
27+ except Exception :
28+ pass
You can’t perform that action at this time.
0 commit comments