Skip to content

Device number fixes#8

Open
szeder wants to merge 2 commits intoDiUS:masterfrom
szeder:device-number-fixes
Open

Device number fixes#8
szeder wants to merge 2 commits intoDiUS:masterfrom
szeder:device-number-fixes

Conversation

@szeder
Copy link

@szeder szeder commented Oct 3, 2021

Fix a bug which likely parses the device number in the argument of the -d option as an octal number, and correct the syntax of the -d option's argument in the help text and the documentation.

szeder added 2 commits October 3, 2021 21:03
The USB device number given as argument to the '-d' option is parsed
with a strtol() call with 0 base.  This is an issue with USB device
numbers that start with a 0 (and they do tend to start with a 0, e.g.
from lsusb output: "Bus 001 Device 014"), because strtol() with 0 base
interprets them as an octal number.  Consequently, the program might not
find the device, or, worse, might find and operate on the wrong device.

Fix this by explicitly specifying base 10 to the strtol() call
converting the device number.

All other strtol() calls already explicitly specify a 10 or 16 base.
For the '-d' option the code expects the bus and device numbers in the
format "bus.dev", i.e. separated by a dot, but the documentation and
help text mention "bus:dev", i.e.  separated by a colon.

Update all documentation and help text to match the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant