From d667002d091413bd2cf3897baaa7885f17856125 Mon Sep 17 00:00:00 2001 From: manunio Date: Mon, 15 Jul 2024 23:06:37 +0530 Subject: [PATCH] python-multipart: fix fuzz blocker (#12221) Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67660 (Fuzz-Blocker) This is a temp fix, till https://github.com/Kludex/python-multipart/pull/141 lands. --- projects/python-multipart/Dockerfile | 1 + projects/python-multipart/build.sh | 1 + projects/python-multipart/multipart.patch | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 projects/python-multipart/multipart.patch diff --git a/projects/python-multipart/Dockerfile b/projects/python-multipart/Dockerfile index 74e406f6b938..99fa74aa32f0 100644 --- a/projects/python-multipart/Dockerfile +++ b/projects/python-multipart/Dockerfile @@ -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/ diff --git a/projects/python-multipart/build.sh b/projects/python-multipart/build.sh index 6dcd940b4425..28635108b36f 100755 --- a/projects/python-multipart/build.sh +++ b/projects/python-multipart/build.sh @@ -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 diff --git a/projects/python-multipart/multipart.patch b/projects/python-multipart/multipart.patch new file mode 100644 index 000000000000..6eeac5b4b252 --- /dev/null +++ b/projects/python-multipart/multipart.patch @@ -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