Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Commit ac6120b

Browse files
hansmisignal11
authored andcommitted
libusb: Fix null pointer dereference in hid_open()
Make sure hid_device_info.serial_number is not null before passing it to wcscmp(). When libusb can't open a device for any reason (e.g. file system permissions), hid_device_info.serial_number is NULL. Make sure hid_device_info.serial_number is not null before passing it to wcscmp(3). Signed-off-by: Michael Hanselmann <[email protected]>
1 parent 171a521 commit ac6120b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libusb/hid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const
619619
if (cur_dev->vendor_id == vendor_id &&
620620
cur_dev->product_id == product_id) {
621621
if (serial_number) {
622-
if (wcscmp(serial_number, cur_dev->serial_number) == 0) {
622+
if (cur_dev->serial_number &&
623+
wcscmp(serial_number, cur_dev->serial_number) == 0) {
623624
path_to_open = cur_dev->path;
624625
break;
625626
}

0 commit comments

Comments
 (0)