aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Lalet <pierre@droids-corp.org>2018-01-19 22:48:17 +0100
committerGitHub <noreply@github.com>2018-01-19 22:48:17 +0100
commit53e17f845514261dfdc29901d7867f10a658f10c (patch)
tree1bb031527003c8759123c55cd5d3fbed9c391ee1
parent45e4c8837ed7d12e6155b5224895096209b6807e (diff)
parent5215a30365a5e5cd95cf8e68d8f61ab19908b2b8 (diff)
downloadscapy-53e17f845514261dfdc29901d7867f10a658f10c.tar.gz
Merge pull request #1063 from HenningCash/fix/pack-s-formatter
Always pass bytes to struct.pack if s formatter is used
-rw-r--r--scapy/arch/bpf/core.py2
-rw-r--r--scapy/arch/bpf/supersocket.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/scapy/arch/bpf/core.py b/scapy/arch/bpf/core.py
index 0340fa6d..040067b1 100644
--- a/scapy/arch/bpf/core.py
+++ b/scapy/arch/bpf/core.py
@@ -173,7 +173,7 @@ def get_working_ifaces():
# Check if the interface can be used
try:
- fcntl.ioctl(fd, BIOCSETIF, struct.pack("16s16x", ifname))
+ fcntl.ioctl(fd, BIOCSETIF, struct.pack("16s16x", ifname.encode()))
interfaces.append((ifname, int(ifname[-1])))
except IOError as err:
pass
diff --git a/scapy/arch/bpf/supersocket.py b/scapy/arch/bpf/supersocket.py
index 34c8f150..7d04e186 100644
--- a/scapy/arch/bpf/supersocket.py
+++ b/scapy/arch/bpf/supersocket.py
@@ -66,7 +66,7 @@ class _L2bpfSocket(SuperSocket):
# Assign the network interface to the BPF handle
try:
- fcntl.ioctl(self.ins, BIOCSETIF, struct.pack("16s16x", self.iface))
+ fcntl.ioctl(self.ins, BIOCSETIF, struct.pack("16s16x", self.iface.encode()))
except IOError:
raise Scapy_Exception("BIOCSETIF failed on %s" % self.iface)
self.assigned_interface = self.iface
@@ -324,7 +324,7 @@ class L3bpfSocket(L2bpfSocket):
# Assign the network interface to the BPF handle
if self.assigned_interface != iff:
try:
- fcntl.ioctl(self.outs, BIOCSETIF, struct.pack("16s16x", iff))
+ fcntl.ioctl(self.outs, BIOCSETIF, struct.pack("16s16x", iff.encode()))
except IOError:
raise Scapy_Exception("BIOCSETIF failed on %s" % iff)
self.assigned_interface = iff