Skip to content

Commit 1e7a629

Browse files
AsyncSniffer: forward error in stop() if never started (#4800)
* Fix AsyncSniffer Attribute Error Signed-off-by: Louis Scalbert <[email protected]> * Forward error + test --------- Signed-off-by: Louis Scalbert <[email protected]> Co-authored-by: gpotter2 <[email protected]>
1 parent 5739035 commit 1e7a629

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

scapy/sendrecv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,11 @@ 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"):
1405+
# Never started -> is there an exception?
1406+
if self.exception is not None:
1407+
raise self.exception
1408+
return None
14041409
if self.continue_sniff:
14051410
raise Scapy_Exception(
14061411
"Unsupported (offline or unsupported socket)"

test/regression.uts

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

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

0 commit comments

Comments
 (0)