Skip to content

Commit

Permalink
python-multipart: fix fuzz blocker (#12221)
Browse files Browse the repository at this point in the history
  • Loading branch information
manunio committed Jul 15, 2024
1 parent 2bac34f commit d667002
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/python-multipart/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ RUN apt-get update && apt-get install -y make autoconf automake libtool
RUN git clone --depth 1 https://github.com/Kludex/python-multipart python-multipart
RUN python3 -m pip install --upgrade pip
WORKDIR python-multipart
COPY *.patch $SRC/python-multipart
COPY build.sh $SRC/
1 change: 1 addition & 0 deletions projects/python-multipart/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
################################################################################

git apply $SRC/python-multipart/*.patch
python3 -m pip install '.[dev]'
for fuzzer in $(find $SRC -name "fuzz_*.py"); do
compile_python_fuzzer $fuzzer
Expand Down
13 changes: 13 additions & 0 deletions projects/python-multipart/multipart.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/multipart/multipart.py b/multipart/multipart.py
index 0bf35c3..2a0e01c 100644
--- a/multipart/multipart.py
+++ b/multipart/multipart.py
@@ -1167,7 +1167,7 @@ class MultipartParser(BaseParser):
# If we've reached a CR at the beginning of a header, it means
# that we've reached the second of 2 newlines, and so there are
# no more headers to parse.
- if c == CR:
+ if c == CR and index == 0:
delete_mark("header_field")
state = MultipartState.HEADERS_ALMOST_DONE
i += 1

0 comments on commit d667002

Please sign in to comment.