Skip to content
Open
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/tools/automotive/obdscanner.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def main():
file=sys.stderr)
sys.exit(1)

if 0 > source >= 0x800 or 0 > destination >= 0x800\
if not (0 <= source < 0x800) or not (0 <= destination < 0x800) \
or source == destination:
print("The ids must be >= 0 and < 0x800 and not equal.",
file=sys.stderr)
Expand Down
28 changes: 28 additions & 0 deletions test/tools/obdscanner.uts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ std_out, std_err = result.communicate()
expected_output = plain_str(b'Scan for all possible obd service classes and their subfunctions.')
assert expected_output in plain_str(std_out)


= Test out of range source id
result = subprocess.Popen([sys.executable, "scapy/tools/automotive/obdscanner.py",
"--interface", "socketcan", "--channel", "vcan0",
"--source", "0x800",
"--destination", "0x7df", "--timeout", "0.01", "-1"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
returncode = result.wait()
std_out, std_err = result.communicate()
assert returncode != 0

expected_output = plain_str(b'The ids must be >= 0 and < 0x800 and not equal.')
assert expected_output in plain_str(std_err)


= Test out of range destination id
result = subprocess.Popen([sys.executable, "scapy/tools/automotive/obdscanner.py",
"--interface", "socketcan", "--channel", "vcan0",
"--source", "0x7e0",
"--destination", "0x800", "--timeout", "0.01", "-1"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
returncode = result.wait()
std_out, std_err = result.communicate()
assert returncode != 0

expected_output = plain_str(b'The ids must be >= 0 and < 0x800 and not equal.')
assert expected_output in plain_str(std_err)

+ Scan tests

= Load contribution layer
Expand Down