From cb4cff2c71e81853d4078a3407a594711d697e87 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 16 May 2021 23:06:04 +0200 Subject: [PATCH] hosted/ftdi: Compare only for length of the string given in the header Devices may have added version like "Tigard V1.1" vs "Tigard" --- src/platforms/hosted/bmp_libusb.c | 4 ++-- src/platforms/hosted/ftdi_bmp.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platforms/hosted/bmp_libusb.c b/src/platforms/hosted/bmp_libusb.c index bef9e09..63aad38 100644 --- a/src/platforms/hosted/bmp_libusb.c +++ b/src/platforms/hosted/bmp_libusb.c @@ -253,13 +253,13 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info) if ((cable->vendor != desc.idVendor) || (cable->product != desc.idProduct)) continue; /* VID/PID do not match*/ if (cl_opts->opt_cable) { - if (strcmp(cable->name, cl_opts->opt_cable)) + if (strncmp(cable->name, cl_opts->opt_cable, strlen(cable->name))) continue; /* cable names do not match*/ else found = true; } if (cable->description) { - if (strcmp(cable->description, product)) + if (strncmp(cable->description, product, strlen(cable->description))) continue; /* discriptions do not match*/ else found = true; diff --git a/src/platforms/hosted/ftdi_bmp.c b/src/platforms/hosted/ftdi_bmp.c index 5386815..f05a86b 100644 --- a/src/platforms/hosted/ftdi_bmp.c +++ b/src/platforms/hosted/ftdi_bmp.c @@ -269,7 +269,7 @@ int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info) int err; cable_desc_t *cable = &cable_desc[0]; for(; cable->name; cable++) { - if (strcmp(cable->name, cl_opts->opt_cable) == 0) + if (strncmp(cable->name, cl_opts->opt_cable, strlen(cable->name)) == 0) break; } @@ -281,7 +281,7 @@ int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info) active_cable = cable; memcpy(&active_state, &active_cable->init, sizeof(data_desc_t)); /* If swd_(read|write) is not given for the selected cable and - the 'r' command line argument is give, assume resistor SWD + the 'e' command line argument is give, assume resistor SWD connection.*/ if (cl_opts->external_resistor_swd && (active_cable->mpsse_swd_read.set_data_low == 0) &&