Skip to content

Commit 02d1ec1

Browse files
manunioKludex
andauthored
fuzz: fix boundary error (#179)
Co-authored-by: Marcelo Trylesinski <[email protected]>
1 parent 616b81e commit 02d1ec1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fuzz/fuzz_form.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ def parse_form_urlencoded(fdp: EnhancedDataProvider) -> None:
2929

3030

3131
def parse_multipart_form_data(fdp: EnhancedDataProvider) -> None:
32-
header = {"Content-Type": "multipart/form-data; boundary=--boundary"}
33-
parse_form(header, io.BytesIO(fdp.ConsumeRandomBytes()), on_field, on_file)
32+
boundary = "boundary"
33+
header = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
34+
body = (
35+
f"--{boundary}\r\n"
36+
f"Content-Type: multipart/form-data; boundary={boundary}\r\n\r\n"
37+
f"{fdp.ConsumeRandomString()}\r\n"
38+
f"--{boundary}--\r\n"
39+
)
40+
parse_form(header, io.BytesIO(body.encode("latin1", errors="ignore")), on_field, on_file)
3441

3542

3643
def TestOneInput(data: bytes) -> None:

0 commit comments

Comments
 (0)