Skip to content

Commit

Permalink
Fix segfault when not with an NK3
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Dec 3, 2024
1 parent 366bb2e commit a6655e7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/operations_ccid.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ int set_pin_ccid(struct Device *dev, const char *admin_PIN) {
int nk3_change_pin(struct Device *dev, const char *old_pin, const char*new_pin) {
libusb_device *usb_dev;
struct libusb_device_descriptor usb_desc;

if (!dev->mp_devhandle_ccid) {
return RET_NO_ERROR;
}

usb_dev = libusb_get_device(dev->mp_devhandle_ccid);

int r = libusb_get_device_descriptor(usb_dev, &usb_desc);
Expand All @@ -76,7 +81,7 @@ int nk3_change_pin(struct Device *dev, const char *old_pin, const char*new_pin)


if (usb_desc.idVendor != NITROKEY_USB_VID || usb_desc.idProduct != NITROKEY_3_USB_PID) {
return 0;
return RET_NO_ERROR;
}

TLV tlvs[] = {
Expand Down

0 comments on commit a6655e7

Please sign in to comment.