From 9604a3ef365b088b2d6b36e04dde6a225b271a56 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 3 Aug 2022 00:04:14 +0100 Subject: [PATCH] Check -U option for unknown memories during parsing $ avrdude -qp ATmega2560 -c usbtiny -U flesh:w:blink-mega2560+lext-test.hex:i avrdude: unknown memory type flesh avrdude: error parsing update operation 'flesh:w:blink-mega2560+lext-test.hex:i' --- src/avr.c | 2 +- src/libavrdude.h | 2 +- src/update.c | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index eb077b32..3a7d4a9e 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1253,7 +1253,7 @@ void avr_add_mem_order(const char *str) { exit(1); } -int avr_known_mem(const char *str) { +int avr_mem_is_known(const char *str) { for(size_t i=0; i < sizeof avr_mem_order/sizeof *avr_mem_order; i++) if(avr_mem_order[i] && !strcmp(avr_mem_order[i], str)) return 1; diff --git a/src/libavrdude.h b/src/libavrdude.h index cc332ec7..f8bdf682 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -821,7 +821,7 @@ int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles); void avr_add_mem_order(const char *str); -int avr_known_mem(const char *str); +int avr_mem_is_known(const char *str); #define disable_trailing_ff_removal() avr_mem_hiaddr(NULL) int avr_mem_hiaddr(AVRMEM * mem); diff --git a/src/update.c b/src/update.c index ffddfa16..ee205bbc 100644 --- a/src/update.c +++ b/src/update.c @@ -62,6 +62,12 @@ UPDATE * parse_op(char * s) return upd; } + if (!avr_mem_is_known(buf)) { + avrdude_message(MSG_INFO, "%s: unknown memory type %s\n", progname, buf); + free(upd); + return NULL; + } + upd->memtype = (char *)malloc(strlen(buf)+1); if (upd->memtype == NULL) { avrdude_message(MSG_INFO, "%s: out of memory\n", progname);