Skip to content

Commit 1726dba

Browse files
committed
Ensure fuzz targets work as expected.
1 parent 5d1bad7 commit 1726dba

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

fuzzing/fuzz_http11_request_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ def test_one_input(data):
2020

2121
try:
2222
next(parser)
23-
except StopIteration:
24-
pass # request is available in exc.value
23+
except StopIteration as exc:
24+
assert isinstance(exc.value, Request)
25+
return
2526
except (
2627
EOFError, # connection is closed without a full HTTP request
2728
SecurityError, # request exceeds a security limit
2829
ValueError, # request isn't well formatted
2930
):
3031
pass
3132

33+
raise RuntimeError("parsing didn't complete")
34+
3235

3336
def main():
3437
atheris.Setup(sys.argv, test_one_input)

fuzzing/fuzz_http11_response_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def test_one_input(data):
2121
)
2222
try:
2323
next(parser)
24-
except StopIteration:
25-
pass # response is available in exc.value
24+
except StopIteration as exc:
25+
assert isinstance(exc.value, Response)
26+
return
2627
except (
2728
EOFError, # connection is closed without a full HTTP response
2829
SecurityError, # response exceeds a security limit
@@ -31,6 +32,8 @@ def test_one_input(data):
3132
):
3233
pass
3334

35+
raise RuntimeError("parsing didn't complete")
36+
3437

3538
def main():
3639
atheris.Setup(sys.argv, test_one_input)

fuzzing/fuzz_websocket_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ def test_one_input(data):
2828

2929
try:
3030
next(parser)
31-
except StopIteration:
32-
pass # response is available in exc.value
31+
except StopIteration as exc:
32+
assert isinstance(exc.value, Frame)
33+
return
3334
except (
3435
PayloadTooBig, # frame's payload size exceeds ``max_size``
3536
ProtocolError, # frame contains incorrect values
3637
):
3738
pass
3839

40+
raise RuntimeError("parsing didn't complete")
41+
3942

4043
def main():
4144
atheris.Setup(sys.argv, test_one_input)

0 commit comments

Comments
 (0)