From 71be95b16a33c5ca86d3b1f03fd74b350881fe14 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 18 Apr 2016 14:47:53 +0000 Subject: [PATCH] In usbhid_open(), correctly calculate the offset for serial number matching. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1389 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 5 +++++ usb_hidapi.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1ef4ff9e..0cba4da4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-04-18 Joerg Wunsch + + * usb_hidapi.c (usbhid_open): Correctly calculate the + offset for serial number matching + 2016-03-28 Joerg Wunsch bug #47550: Linux GPIO broken diff --git a/usb_hidapi.c b/usb_hidapi.c index 6af5dd53..81e9c4ab 100644 --- a/usb_hidapi.c +++ b/usb_hidapi.c @@ -108,7 +108,9 @@ static int usbhid_open(char * port, union pinfo pinfo, union filedescriptor *fd) { avrdude_message(MSG_NOTICE, "%s: usbhid_open(): Found %ls, serno: %ls\n", progname, walk->product_string, walk->serial_number); - if (wcscmp(walk->serial_number + serlen, wserno) == 0) + size_t slen = wcslen(walk->serial_number); + if (slen >= serlen && + wcscmp(walk->serial_number + slen - serlen, wserno) == 0) { /* found matching serial number */ break;