mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 02:10:59 +00:00
fix tnetstread crash found via fuzzing
This commit is contained in:
parent
ca1229d60f
commit
fcec63eebc
@ -46,7 +46,7 @@ class FlowReader:
|
|||||||
if mdata["type"] not in FLOW_TYPES:
|
if mdata["type"] not in FLOW_TYPES:
|
||||||
raise exceptions.FlowReadException("Unknown flow type: {}".format(mdata["type"]))
|
raise exceptions.FlowReadException("Unknown flow type: {}".format(mdata["type"]))
|
||||||
yield FLOW_TYPES[mdata["type"]].from_state(mdata)
|
yield FLOW_TYPES[mdata["type"]].from_state(mdata)
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError, IndexError) as e:
|
||||||
if str(e) == "not a tnetstring: empty file":
|
if str(e) == "not a tnetstring: empty file":
|
||||||
return # Error is due to EOF
|
return # Error is due to EOF
|
||||||
raise exceptions.FlowReadException("Invalid data format.")
|
raise exceptions.FlowReadException("Invalid data format.")
|
||||||
|
@ -11,6 +11,7 @@ from mitmproxy.io import FlowReader, tnetstring
|
|||||||
class TestFlowReader:
|
class TestFlowReader:
|
||||||
@given(binary())
|
@given(binary())
|
||||||
@example(b'51:11:12345678901#4:this,8:true!0:~,4:true!0:]4:\\x00,~}')
|
@example(b'51:11:12345678901#4:this,8:true!0:~,4:true!0:]4:\\x00,~}')
|
||||||
|
@example(b'0:')
|
||||||
def test_fuzz(self, data):
|
def test_fuzz(self, data):
|
||||||
f = io.BytesIO(data)
|
f = io.BytesIO(data)
|
||||||
reader = FlowReader(f)
|
reader = FlowReader(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user