Skip to content

Commit

Permalink
Don't fail if device does not return a string descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
ataradov committed Jan 20, 2024
1 parent c983cef commit 5d77d4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dbg_lin.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ static char *get_string(int fd, int index)
ctrl.timeout = CONTROL_TIMEOUT;

int res = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
check(res >= 0, "ioctl(CONTROL): %d", res);

if (res < 0)
return "";

check(res >= 2 && 0 == (res % 2), "invalid string descriptor response");

int len = res/2 - 1;
Expand Down

0 comments on commit 5d77d4a

Please sign in to comment.