Skip to content

Commit

Permalink
fuzz: fix boundary error (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
manunio and Kludex authored Oct 31, 2024
1 parent 616b81e commit 02d1ec1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fuzz/fuzz_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ def parse_form_urlencoded(fdp: EnhancedDataProvider) -> None:


def parse_multipart_form_data(fdp: EnhancedDataProvider) -> None:
header = {"Content-Type": "multipart/form-data; boundary=--boundary"}
parse_form(header, io.BytesIO(fdp.ConsumeRandomBytes()), on_field, on_file)
boundary = "boundary"
header = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
body = (
f"--{boundary}\r\n"
f"Content-Type: multipart/form-data; boundary={boundary}\r\n\r\n"
f"{fdp.ConsumeRandomString()}\r\n"
f"--{boundary}--\r\n"
)
parse_form(header, io.BytesIO(body.encode("latin1", errors="ignore")), on_field, on_file)


def TestOneInput(data: bytes) -> None:
Expand Down

0 comments on commit 02d1ec1

Please sign in to comment.