Skip to content

Commit 26b3ab6

Browse files
authored
python-multipart: add patch (#13093)
This pr includes a temp patch, will move this upstream once properly tested.
1 parent f2d4acd commit 26b3ab6

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

projects/python-multipart/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ RUN apt-get update && apt-get install -y make autoconf automake libtool
1919
RUN git clone --depth 1 https://github.com/Kludex/python-multipart python-multipart
2020
RUN python3 -m pip install --upgrade pip
2121
WORKDIR python-multipart
22+
COPY *.patch $SRC/python-multipart
2223
COPY build.sh *.options $SRC/

projects/python-multipart/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616
################################################################################
1717

18+
git apply $SRC/python-multipart/*.patch
1819
python3 -m pip install '.[dev]'
1920
for fuzzer in $(find $SRC -name "fuzz_*.py"); do
2021
compile_python_fuzzer $fuzzer
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/fuzz/fuzz_form.py b/fuzz/fuzz_form.py
2+
index 9a3d854..fbc6ad9 100644
3+
--- a/fuzz/fuzz_form.py
4+
+++ b/fuzz/fuzz_form.py
5+
@@ -29,7 +29,7 @@ def parse_form_urlencoded(fdp: EnhancedDataProvider) -> None:
6+
7+
8+
def parse_multipart_form_data(fdp: EnhancedDataProvider) -> None:
9+
- boundary = "boundary"
10+
+ boundary = fdp.ConsumeRandomStringOfSize(16) or "boundary"
11+
header = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
12+
body = (
13+
f"--{boundary}\r\n"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/fuzz/helpers.py b/fuzz/helpers.py
2+
index 7fcd45c..d107cc1 100644
3+
--- a/fuzz/helpers.py
4+
+++ b/fuzz/helpers.py
5+
@@ -1,9 +1,11 @@
6+
import atheris
7+
8+
-
9+
class EnhancedDataProvider(atheris.FuzzedDataProvider):
10+
def ConsumeRandomBytes(self) -> bytes:
11+
return self.ConsumeBytes(self.ConsumeIntInRange(0, self.remaining_bytes()))
12+
13+
def ConsumeRandomString(self) -> str:
14+
return self.ConsumeUnicodeNoSurrogates(self.ConsumeIntInRange(0, self.remaining_bytes()))
15+
+
16+
+ def ConsumeRandomStringOfSize(self, val: int) -> str:
17+
+ return self.ConsumeUnicodeNoSurrogates(self.ConsumeIntInRange(0, val))

0 commit comments

Comments
 (0)