diff --git a/src/gdb_main.c b/src/gdb_main.c index 4c8c1de9f4b..22826e7be76 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -761,10 +761,11 @@ static void exec_v_cont(const char *packet, const size_t length) static void exec_v_flash_erase(const char *packet, const size_t length) { (void)length; - uint32_t addr = 0; - uint32_t len = 0; + uint32_t addr; + uint32_t len; + const char *rest = NULL; - if (sscanf(packet, "%08" PRIx32 ",%08" PRIx32, &addr, &len) == 2) { + if (read_hex32(packet, &rest, &addr, ',') && read_hex32(rest, NULL, &len, READ_HEX_NO_FOLLOW)) { /* Erase Flash Memory */ DEBUG_GDB("Flash Erase %08" PRIX32 " %08" PRIX32 "\n", addr, len); if (!cur_target) { @@ -778,7 +779,8 @@ static void exec_v_flash_erase(const char *packet, const size_t length) target_flash_complete(cur_target); gdb_putpacketz("EFF"); } - } + } else + gdb_putpacketz("EFF"); } static void exec_v_flash_write(const char *packet, const size_t length)