From dba888a00dc9f3a874dce128411afa1415e05e5a Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Mon, 19 May 2025 17:42:07 +0200 Subject: [PATCH 1/5] Harden usbproduct/usbvendor access --- src/usbasp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/usbasp.c b/src/usbasp.c index f3ab5085b..86e01772b 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -165,10 +165,10 @@ static int usbasp_transmit(const PROGRAMMER *pgm, unsigned char receive, unsigned char functionid, const unsigned char *send, unsigned char *buffer, int buffersize); #ifdef USE_LIBUSB_1_0 -static int usbOpenDevice(const PROGRAMMER *pgm, libusb_device_handle ** device, int vendor, +static int usbOpenDevice(const PROGRAMMER *pgm, libusb_device_handle **device, int vendor, const char *vendorName, int product, const char *productName, const char *port); #else -static int usbOpenDevice(const PROGRAMMER *pgm, usb_dev_handle ** device, int vendor, +static int usbOpenDevice(const PROGRAMMER *pgm, usb_dev_handle **device, int vendor, const char *vendorName, int product, const char *productName, const char *port); #endif @@ -448,7 +448,7 @@ static int check_for_port_argument_match(const char *port, char *bus, char *devi */ #ifdef USE_LIBUSB_1_0 -static int usbOpenDevice(const PROGRAMMER *pgm, libusb_device_handle ** device, int vendor, +static int usbOpenDevice(const PROGRAMMER *pgm, libusb_device_handle **device, int vendor, const char *vendorName, int product, const char *productName, const char *port) { libusb_device_handle *handle = NULL; @@ -538,7 +538,7 @@ static int usbOpenDevice(const PROGRAMMER *pgm, libusb_device_handle ** device, return errorCode; } #else -static int usbOpenDevice(const PROGRAMMER *pgm, usb_dev_handle ** device, int vendor, +static int usbOpenDevice(const PROGRAMMER *pgm, usb_dev_handle **device, int vendor, const char *vendorName, int product, const char *productName, const char *port) { struct usb_bus *bus; @@ -656,12 +656,10 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) { } pmsg_error("cannot find USB device with vid=0x%x pid=0x%x", vid, pid); - if(pgm->usbvendor[0] != 0) { + if(pgm->usbvendor && *pgm->usbvendor) msg_error(" vendor='%s'", pgm->usbvendor); - } - if(pgm->usbproduct[0] != 0) { + if(pgm->usbproduct && *pgm->usbproduct) msg_error(" product='%s'", pgm->usbproduct); - } msg_error("\n"); return -1; } From 3c746b4b6b3e33a3a03f32ca550ccd7111c91cc7 Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Mon, 19 May 2025 17:42:47 +0200 Subject: [PATCH 2/5] Simplify help message --- src/stk500v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stk500v2.c b/src/stk500v2.c index 7c193b510..014b70ce6 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -2035,7 +2035,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp msg_error("%s -c %s extended options:\n", progname, pgmid); if(pgm->extra_features & HAS_SUFFER) { msg_error(" -x suffer Read SUFFER register value\n"); - msg_error(" -x suffer= Set SUFFER register value to =0x.., 0... or decimal\n"); + msg_error(" -x suffer= Set SUFFER register value to \n"); } if(pgm->extra_features & HAS_VTARG_SWITCH) { msg_error(" -x vtarg_switch Read on-board target voltage switch state\n"); From ac6be8485b361475800455a0e6bd2b495ab5603f Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Mon, 19 May 2025 17:43:22 +0200 Subject: [PATCH 3/5] Shorten error message --- src/pickit5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pickit5.c b/src/pickit5.c index bcf7cfb12..6429bb82a 100644 --- a/src/pickit5.c +++ b/src/pickit5.c @@ -1428,9 +1428,9 @@ static int pickit5_read_dev_id(const PROGRAMMER *pgm, const AVRPART *p) { pickit5_send_script_cmd(pgm, scr, scr_len, NULL, 0); pickit5_program_enable(pgm, p); if(my.rxBuf[17] == 0x0E) { // Errors figured out during 6 hours of failing to get it to work - if(my.rxBuf[16] == 0x10 || my.rxBuf[16] == 58) { // with the serial/bootloader auto-reset circuit on Arduino board - pmsg_error("debugWIRE transmission error, aborting"); - msg_error("(make sure there are no caps and a pullup >= 10kOhm on the Reset line)\n"); + if(my.rxBuf[16] == 0x10 || my.rxBuf[16] == 58) { // Serial/bootloader auto-reset circuit on Arduino board + pmsg_error("debugWIRE transmission error, aborting" + " (ensure reset has a pullup >= 10 kOhm and no cap)\n"); } else { pmsg_error("%d\n", my.rxBuf[16]); } From e7d40ed78584bfe1e3c7bc2324b27255b6e9855a Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Tue, 20 May 2025 12:14:29 +0200 Subject: [PATCH 4/5] Verbally describe trailing = in help text --- src/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 622b2655a..a56dbe87a 100644 --- a/src/term.c +++ b/src/term.c @@ -1733,7 +1733,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c "to show that of . Wildcards or initial strings are permitted (but\n" "not both), in which case all settings of matching properties are displayed.\n" "\n" - "avrdude> config =\n" + "avrdude> config = # note the trailing = as in config eesave=\n" "\n" "shows all possible values that can take on with the currently\n" "set one being the only that is not commented out. Assignments\n" From f2067ebd80125d7bbc2cadc5c21c73f9a3a7c83c Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Tue, 20 May 2025 12:22:04 +0200 Subject: [PATCH 5/5] Capitalise clarifying comment in help text --- src/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index a56dbe87a..cc5e23d4e 100644 --- a/src/term.c +++ b/src/term.c @@ -1733,7 +1733,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c "to show that of . Wildcards or initial strings are permitted (but\n" "not both), in which case all settings of matching properties are displayed.\n" "\n" - "avrdude> config = # note the trailing = as in config eesave=\n" + "avrdude> config = # Note the trailing = as in config eesave=\n" "\n" "shows all possible values that can take on with the currently\n" "set one being the only that is not commented out. Assignments\n"