Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scapy/arch/windows/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def recv_raw(self, x=MTU):

def close(self):
# type: () -> None
if not self.closed and self.promisc:
if not self.closed and self.promisc and hasattr(self, 'ins'):
self.ins.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
super(L3WinSocket, self).close()

Expand Down
21 changes: 21 additions & 0 deletions test/windows.uts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ def _test():

retry_test(_test)

= Test L3WinSocket close() with partial initialization
~ windows

from scapy.arch.windows.native import L3WinSocket
import socket

# Create partially initialized L3WinSocket
ws = object.__new__(L3WinSocket)
ws.closed = False
ws.promisc = True
# Note: ws.ins is intentionally not set

# This should not raise AttributeError
try:
ws.close()
test_passed = True
except AttributeError:
test_passed = False

assert test_passed, "L3WinSocket.close() raised AttributeError on partially initialized object"

= Leave native mode

conf.use_pcap = True
Expand Down
Loading