Smart card reader causes libusb crash
See original GitHub issueInsert and unplug the smart card reader on windows platform causes libusb crash. releated issues #285
static char *parse_device_interface_path(const char *interface_path)
{
char *device_id, *guid_start;
unsigned int i, len;
len = safe_strlen(interface_path);
if (len < 4) {
return NULL;
}
// Microsoft indiscriminatly uses '\\?\', '\\.\', '##?#" or "##.#" for root prefixes.
if (((interface_path[0] == '\\') && (interface_path[1] == '\\') && (interface_path[3] == '\\')) ||
((interface_path[0] == '#') && (interface_path[1] == '#') && (interface_path[3] == '#'))) {
interface_path += 4;
len -= 4;
}
guid_start = strchr(interface_path, '{');
if (guid_start != NULL) {
len = (guid_start - interface_path) - 1; // One more for separator
}
if (len <= 0) {
usbi_err(NULL, "program assertion failed: invalid device interface path");
return NULL;
}
device_id = calloc(len + 1, 1); // One additional for NULL term.
if (device_id == NULL) {
return NULL;
}
strncat(device_id, interface_path, len);
// Now convert to uppercase and replace '#' with '\'
for (i = 0; i < len; i++) {
device_id[i] = (char)toupper((int)device_id[i]);
if (device_id[i] == '#')
device_id[i] = '\\';
}
return device_id;
}
The unsigned int len cause the len
Value cannot be negative
and then Cause the code if(len<=0)
not to be executed
when len should be -1;
device_id[i] emit Array out of bounds exception
Just need to modify unsigned int len
to int len
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
pcscd crashes when disconnecting / reconnecting USB device
I have libusb only in use for the smart card reader and for a scanner. The scanner is addressed by xsane and this...
Read more >USB card readers crash computer in Windows 8
I am having problems getting two of my computers to work with card readers. Both are Windows 8 and one of the two...
Read more >August 2010 - Ludovic Rousseau's blog
If libusb is used by pcsc-lite the USB bus is scanned every 1 second. ... The card status is asked by pcscd to...
Read more >Charon crash issue on remote device after restart on local ...
Charon crash issue due to usage of smartcard-hsm ... operations using the PKCS#11 with the same device, card reader and smart cards, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having the same Issue. Thank you @xdimh now can I patch it in my project.
Dont you @xdimh want to create a PR so that the node-usb Team can apply it faster?
Excellent, closing. Please re open this if required.