Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

sniffer: script: ignore non-ASCII characters on input #35

Merged
merged 1 commit into from
Jul 14, 2018
Merged
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
8 changes: 4 additions & 4 deletions sniffer/tools/sniffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def configure_interface(port, channel):
print("Application has no network interface defined",
file=sys.stderr)
sys.exit(2)
match = re.search(r'^Iface +(\d+)', line.decode())
match = re.search(r'^Iface +(\d+)', line.decode(errors="ignore"))
if match is not None:
iface = int(match.group(1))
break
Expand All @@ -85,7 +85,7 @@ def generate_pcap(port, out):
line = port.readline().rstrip()

pkt_header = re.match(r">? *rftest-rx --- len 0x(\w\w).*",
line.decode())
line.decode(errors="ignore"))
if pkt_header:
now = time()
sec = int(now)
Expand All @@ -97,9 +97,9 @@ def generate_pcap(port, out):
sys.stderr.write("RX: %i\r" % count)
continue

pkt_data = re.match(r"(0x\w\w )+", line.decode())
pkt_data = re.match(r"(0x\w\w )+", line.decode(errors="ignore"))
if pkt_data:
for part in line.decode().split(' '):
for part in line.decode(errors="ignore").split(' '):
byte = re.match(r"0x(\w\w)", part)
if byte:
out.write(pack('<B', int(byte.group(1), 16)))
Expand Down