From f4569740492c4255d546d5129b45c08e509cc8a1 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Mon, 9 Nov 2026 04:30:54 +0000 Subject: [PATCH] OSS-Fuzz: Add new fuzzer/dict/corpus/scripts targets datetime processing Signed-off-by: Arthur Chan --- Makefile | 5 ++++- corp-datetime/date_0 | Bin 0 -> 12 bytes corp-datetime/date_1 | Bin 0 -> 12 bytes corp-datetime/date_2 | Bin 0 -> 12 bytes corp-datetime/date_3 | Bin 0 -> 12 bytes corp-datetime/datetime_0 | 1 + corp-datetime/datetime_1 | 1 + corp-datetime/datetime_2 | 1 + corp-datetime/datetime_3 | 1 + corp-datetime/datetime_4 | 1 + corp-datetime/datetime_5 | 1 + corp-datetime/datetime_6 | 1 + corp-datetime/datetime_7 | 1 + corp-datetime/time_0 | 1 + corp-datetime/time_1 | 1 + corp-datetime/time_2 | 1 + corp-datetime/time_3 | 1 + corp-datetime/time_4 | 1 + corp-datetime/time_5 | 1 + corp-datetime/time_6 | 1 + corp-datetime/time_7 | 1 + corp-datetime/time_8 | 1 + datetime.py | 45 +++++++++++++++++++++++++++++++++++++++ fuzz_targets.txt | 1 + fuzzer-datetime.dict | 33 ++++++++++++++++++++++++++++ 25 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 corp-datetime/date_0 create mode 100644 corp-datetime/date_1 create mode 100644 corp-datetime/date_2 create mode 100644 corp-datetime/date_3 create mode 100644 corp-datetime/datetime_0 create mode 100644 corp-datetime/datetime_1 create mode 100644 corp-datetime/datetime_2 create mode 100644 corp-datetime/datetime_3 create mode 100644 corp-datetime/datetime_4 create mode 100644 corp-datetime/datetime_5 create mode 100644 corp-datetime/datetime_6 create mode 100644 corp-datetime/datetime_7 create mode 100644 corp-datetime/time_0 create mode 100644 corp-datetime/time_1 create mode 100644 corp-datetime/time_2 create mode 100644 corp-datetime/time_3 create mode 100644 corp-datetime/time_4 create mode 100644 corp-datetime/time_5 create mode 100644 corp-datetime/time_6 create mode 100644 corp-datetime/time_7 create mode 100644 corp-datetime/time_8 create mode 100644 datetime.py create mode 100644 fuzzer-datetime.dict diff --git a/Makefile b/Makefile index 01df3e8..9623816 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -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 +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 fuzzer-datetime PYTHON_CONFIG_PATH=$(CPYTHON_INSTALL_PATH)/bin/python3-config CXXFLAGS += $(shell $(PYTHON_CONFIG_PATH) --cflags) @@ -42,3 +42,6 @@ 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 + +fuzzer-datetime: + clang++ $(CXXFLAGS) $(LIB_FUZZING_ENGINE) -std=c++17 fuzzer.cpp -DPYTHON_HARNESS_PATH="\"datetime.py\"" -ldl $(LDFLAGS) -o fuzzer-datetime diff --git a/corp-datetime/date_0 b/corp-datetime/date_0 new file mode 100644 index 0000000000000000000000000000000000000000..8ace41233710041fcfd6727f5d6e4ac3de3055c6 GIT binary patch literal 12 TcmZQzH8LdLjViD0t)~D literal 0 HcmV?d00001 diff --git a/corp-datetime/date_3 b/corp-datetime/date_3 new file mode 100644 index 0000000000000000000000000000000000000000..54719f4712541a05726ae3ff0248065055848ea3 GIT binary patch literal 12 TcmZQzH8L %r" % (parsed, parsed.isoformat()) + ) + + delta = timedelta(amount % 30, amount % 60, amount % 1000000) + try: + parsed + delta + parsed - delta + except (TypeError, OverflowError): + pass diff --git a/fuzz_targets.txt b/fuzz_targets.txt index b016889..2f1aea5 100644 --- a/fuzz_targets.txt +++ b/fuzz_targets.txt @@ -2,6 +2,7 @@ ast ast.py binascii binascii.py configparser configparser.py csv csv.py +datetime datetime.py decode decode.py difflib difflib.py email email.py diff --git a/fuzzer-datetime.dict b/fuzzer-datetime.dict new file mode 100644 index 0000000..6824d4d --- /dev/null +++ b/fuzzer-datetime.dict @@ -0,0 +1,33 @@ +# ISO-8601 tokens for date/time/datetime.fromisoformat +"T" +"Z" +"z" +"+01:00" +"+01:00:30" +"-05:30" +"+0000" +"+01" +"2024-01-15" +"2024-01-15T10:30" +"2024-01-15 10:30:00" +"10:30" +"10:30:00" +"10:30:00.123456" +"10:30:00,5" +".123456" +",123" +"24:00" +"00:00" +"W" +"-W" +"2024-W03-1" +"2024-W03" +"2024-021" +"0001-01-01" +"9999-12-31" +"23:59:59.999999" +"+23:59" +"-23:59" +"hh" +"mm" +"ss"