Skip to content

Commit ce53248

Browse files
committed
Forward error + test
1 parent 3dc5a88 commit ce53248

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

scapy/sendrecv.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,12 @@ def stop(self, join=True):
14011401
"""Stops AsyncSniffer if not in async mode"""
14021402
if self.running:
14031403
self.stop_cb()
1404-
if not hasattr(self, "continue_sniff") or self.continue_sniff:
1404+
if not hasattr(self, "continue_sniff"):
1405+
# Never started -> is there an exception?
1406+
if self.exception is not None:
1407+
raise self.exception
1408+
return
1409+
if self.continue_sniff:
14051410
raise Scapy_Exception(
14061411
"Unsupported (offline or unsupported socket)"
14071412
)

test/regression.uts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,14 @@ try:
17871787
except ValueError:
17881788
assert True
17891789

1790+
try:
1791+
sniffer = AsyncSniffer(iface="this_interface_does_not_exists")
1792+
sniffer.start()
1793+
sniffer.stop()
1794+
assert False, "Should have errored by now"
1795+
except ValueError:
1796+
assert True
1797+
17901798
= Sending a TCP syn 'forever' at layer 2 and layer 3
17911799
~ netaccess needs_root IP
17921800
def _test():

0 commit comments

Comments
 (0)