Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: google/oss-fuzz
# Temporary, for testing use my branch with the updated build scripts.
repository: stanfromireland/oss-fuzz
ref: merge-cpython3-python3-libraries
path: oss-fuzz
persist-credentials: false

Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
all: fuzzer-binascii 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
C_FUZZ_TESTS := $(shell cat fuzz_tests.txt)

all: fuzzer-binascii 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 $(C_FUZZ_TESTS)

PYTHON_CONFIG_PATH=$(CPYTHON_INSTALL_PATH)/bin/python3-config
CFLAGS += $(shell $(PYTHON_CONFIG_PATH) --cflags)
CXXFLAGS += $(shell $(PYTHON_CONFIG_PATH) --cflags)
LDFLAGS += -rdynamic $(shell $(PYTHON_CONFIG_PATH) --ldflags --embed) $(CPYTHON_MODLIBS) -Wl,--allow-multiple-definition

Expand Down Expand Up @@ -42,3 +45,8 @@ fuzzer-xml:
clang++ $(CXXFLAGS) $(LIB_FUZZING_ENGINE) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH="\"xml.py\"" -ldl $(LDFLAGS) -o fuzzer-xml
fuzzer-zoneinfo:
clang++ $(CXXFLAGS) $(LIB_FUZZING_ENGINE) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH="\"zoneinfo.py\"" -ldl $(LDFLAGS) -o fuzzer-zoneinfo

# C fuzz targets
$(C_FUZZ_TESTS): %: fuzzer.c
clang $(CFLAGS) -D _Py_FUZZ_ONE -D _Py_FUZZ_$@ -c -Wno-unused-function fuzzer.c -o $@.o
clang++ $(CXXFLAGS) -rdynamic $@.o $(LIB_FUZZING_ENGINE) $(LDFLAGS) -o $@
134 changes: 134 additions & 0 deletions dictionaries/fuzz_elementtree_parsewhole.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
tok_1="<"
tok_2=">"
tok_3="/"
tok_4="<![CDATA["
tok_5="]]>"
tok_6="<?xml"
tok_6a="?>"
tok_7="version"
tok_8="encoding"
tok_9="UTF-8"
tok_9a="UTF-16"
tok_9b="ASCII"
tok_9c="LATIN-1"
tok_9d="UTF-32"
tok_9e="UTF-7"
tok_10="\""
tok_11="&"
tok_11a="&#"
tok_11b=";"
tok_12="'"
tok_13="<!--"
tok_13a="-->"
tok_14="</"
tok_15="="
tok_16="&gt;"
tok_17="&lt;"
tok_18="&amp;"
tok_19="&apos;"
tok_20="&quot;"
tok_21="&#20013;"
tok_22="&#x4e2d;"
tok_23="&#0;"
tok_24="<!ENTITY"
tok_25="SYSTEM"
tok_26="PUBLIC"
tok_27="NDATA"
tok_28="["
tok_29="]"
tok_30="\\"
tok_30a="\\x00"
tok_31="0"
tok_32="1"
tok_33="2"
tok_34="3"
tok_35="4"
tok_36="5"
tok_37="6"
tok_38="7"
tok_39="8"
tok_40="9"
tok_41="iso8859_1"
tok_42="latin_1"
tok_43="us.ascii"
tok_43a="us_ascii"
tok_43b="ascii"
tok_44="xml:"
tok_45="surrogate"
tok_46="replace"
tok_47="strict"

attr_encoding=" encoding=\"1\""
attr_generic=" a=\"1\""
attr_href=" href=\"1\""
attr_standalone=" standalone=\"no\""
attr_version=" version=\"1\""
attr_xml_base=" xml:base=\"1\""
attr_xml_id=" xml:id=\"1\""
attr_xml_lang=" xml:lang=\"1\""
attr_xml_space=" xml:space=\"1\""
attr_xmlns=" xmlns=\"1\""

entity_builtin="&lt;"
entity_decimal="&#1;"
entity_external="&a;"
entity_hex="&#x1;"

string_any="ANY"
string_brackets="[]"
string_cdata="CDATA"
string_col_fallback=":fallback"
string_col_generic=":a"
string_col_include=":include"
string_dashes="--"
string_empty="EMPTY"
string_empty_dblquotes="\"\""
string_empty_quotes="''"
string_entities="ENTITIES"
string_entity="ENTITY"
string_fixed="#FIXED"
string_id="ID"
string_idref="IDREF"
string_idrefs="IDREFS"
string_implied="#IMPLIED"
string_nmtoken="NMTOKEN"
string_nmtokens="NMTOKENS"
string_notation="NOTATION"
string_parentheses="()"
string_pcdata="#PCDATA"
string_percent="%a"
string_public="PUBLIC"
string_required="#REQUIRED"
string_schema=":schema"
string_system="SYSTEM"
string_ucs4="UCS-4"
string_utf16="UTF-16"
string_utf8="UTF-8"
string_xmlns="xmlns:"

tag_attlist="<!ATTLIST"
tag_cdata="<![CDATA["
tag_close="</a>"
tag_doctype="<!DOCTYPE"
tag_element="<!ELEMENT"
tag_entity="<!ENTITY"
tag_ignore="<![IGNORE["
tag_include="<![INCLUDE["
tag_notation="<!NOTATION"
tag_open="<a>"
tag_open_close="<a />"
tag_open_exclamation="<!"
tag_open_q="<?"
tag_sq2_close="]]>"
tag_xml_q="<?xml?>"

encoding_utf="UTF-"
encoding_iso1="ISO-8859"
encoding_iso3="ISO-10646-UCS"
encoding_iso5="ISO-LATIN-1"
encoding_jis="SHIFT_JIS"
encoding_utf7="UTF-7"
encoding_utf16le="UTF-16BE"
encoding_utf16le="UTF-16LE"
encoding_ascii="US-ASCII"
encoding_latin1="latin1"
40 changes: 40 additions & 0 deletions dictionaries/fuzz_json_loads.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"0"
",0"
":0"
"0:"
"-1.2e+3"

"true"
"false"
"null"

"\"\""
",\"\""
":\"\""
"\"\":"

"{}"
",{}"
":{}"
"{\"\":0}"
"{{}}"

"[]"
",[]"
":[]"
"[0]"
"[[]]"

"''"
"\\"
"\\b"
"\\f"
"\\n"
"\\r"
"\\t"
"\\u0000"
"\\x00"
"\\0"
"\\uD800\\uDC00"
"\\uDBFF\\uDFFF"

186 changes: 186 additions & 0 deletions dictionaries/fuzz_pycompile.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# bits of syntax
"( "
") "
"[ "
"] "
": "
", "
"; "
"{ "
"} "

# operators
"+ "
"- "
"* "
"** "
"/ "
"// "
"| "
"& "
"< "
"> "
"= "
". "
"% "
"` "
"^ "
"~ "
"@ "
"== "
"!= "
"<> "
"<< "
"<= "
">= "
">> "
"+= "
"-= "
"*= "
"** "
"/= "
"//= "
"|= "
"%= "
"&= "
"^= "
"<<= "
">>= "
"**= "
":= "
"@= "

# whitespace
" "
"\\t"
":\\n "
"\\\\n"

# type signatures and functions
"-> "
": List[int]"
": Dict[int, str]"

"# type:"
"# type: List[int]"
"# type: Dict[int, str]"

", *"
", /"
", *args"
", **kwargs"
", x=42"


# literals
"0x0a"
"0b0000"
"42"
"0o70"
"42j"
"42.01"
"-5"
"+42e-3"
"0_0_0"
"1e1_0"
".1_4"

"{}"

# variable names
"x"
"y"
"_"
"*x"

# strings
"r'x'"

"b'x'"

"rb\"x\""

"br\"x\""

"u\"x\""

"f'{x + 5}'"
"f\"{x + 5}\""
"f'{s!r}'"
"f'{s!s}'"
"f'{s!a}'"
"f'{x=}'"

"t'{s + 5}'"
"t\"{s + 5}\""
"tr's'"
"rt\"s\""

"'''"
"\"\"\""

"\\N"
"\\u"
"\\x"

# keywords
"def "
"del "
"pass "
"break "
"continue "
"return "
"raise "
"from "
"import "
".. "
"... "
"__future__ "
"as "
"global "
"nonlocal "
"assert "
"print "
"if "
"elif "
"else: "
"while "
"try: "
"except "
"except* "
"finally: "
"with "
"lambda "
"or "
"and "
"not "
"None "
"__peg_parser__"
"True "
"False "
"yield "
"async "
"await "
"for "
"in "
"is "
"class "
"match "
"case "
"type "
"lazy "

# shebangs and encodings
"#!"
"# coding:"
"# coding="
"# coding: latin-1"
"# coding=latin-1"
"# coding: utf-8"
"# coding=utf-8"
"# coding: ascii"
"# coding=ascii"
"# coding: cp860"
"# coding=cp860"
"# coding: gbk"
"# coding=gbk"
Loading
Loading