From 2f324918b3f6611d885fe8bd0807e1ec48f51b4f Mon Sep 17 00:00:00 2001 From: Martijn Plak Date: Tue, 23 Jan 2024 08:36:53 +0100 Subject: [PATCH 1/3] readmem: fix entry of numbers and allow hexadecimal --- client/src/cmdhw.c | 6 +++--- client/src/proxmark3.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 572516639..e9f05ce30 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -640,10 +640,10 @@ static int CmdReadmem(const char *Cmd) { void *argtable[] = { arg_param_begin, - arg_int0("a", "adr", "", "flash address to start reading from"), - arg_int0("l", "len", "", "length (default 32 or 512KB)"), + arg_u64_0("a", "adr", "", "flash address to start reading from"), + arg_u64_0("l", "len", "", "length (default 32 or 512KB)"), arg_str0("f", "file", "", "save to file"), - arg_int0("c", "cols", "", "column breaks"), + arg_u64_0("c", "cols", "", "column breaks"), arg_lit0("r", "raw", "use raw address mode: read from anywhere, not just flash"), arg_param_end }; diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index a6cfe1dd7..024258819 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -1139,7 +1139,7 @@ int main(int argc, char *argv[]) { show_help(false, exec_name); return 1; } - uint32_t tmpaddr = strtol(argv[i + 1], NULL, 10); + uint32_t tmpaddr = strtoul(argv[i + 1], NULL, 0); dumpmem_addr = tmpaddr; i++; continue; @@ -1150,7 +1150,7 @@ int main(int argc, char *argv[]) { show_help(false, exec_name); return 1; } - uint32_t tmplen = strtol(argv[i + 1], NULL, 10); + uint32_t tmplen = strtoul(argv[i + 1], NULL, 0); dumpmem_len = tmplen; i++; continue; From 6524c7ada787099fdcb535acaea4c70315bd3e17 Mon Sep 17 00:00:00 2001 From: Martijn Plak Date: Tue, 23 Jan 2024 08:39:50 +0100 Subject: [PATCH 2/3] readmem: remove superfluous printing of filename --- client/src/cmdhw.c | 1 - client/src/proxmark3.c | 1 - 2 files changed, 2 deletions(-) diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index e9f05ce30..f26f1cb6d 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -682,7 +682,6 @@ static int CmdReadmem(const char *Cmd) { } if (save_to_file) { - PrintAndLogEx(INFO, "saving to "_YELLOW_("%s"), filename); saveFile(filename, ".bin", buffer, len); } else { PrintAndLogEx(INFO, "---- " _CYAN_("processor%s memory") " ----", flash_str); diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 024258819..e267faa9d 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -683,7 +683,6 @@ static int dumpmem_to_file(const char *filename, uint32_t addr, uint32_t len, bo } if (res == PM3_SUCCESS) { - PrintAndLogEx(INFO, "saving to "_YELLOW_("%s"), filename); if (saveFile(filename, ".bin", buffer, read) != 0) { PrintAndLogEx(ERR, "error writing to file "_YELLOW_("%s"), filename); res = PM3_EFILE; From ebdd30e92cc37d5a4120d399f8728615c313f917 Mon Sep 17 00:00:00 2001 From: Martijn Plak Date: Tue, 23 Jan 2024 08:41:53 +0100 Subject: [PATCH 3/3] readmem (ARM): boundary check against end of addressable space --- armsrc/appmain.c | 3 +++ bootrom/bootrom.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 7032983f7..71febb7e2 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -2393,6 +2393,9 @@ static void PacketReceived(PacketCommandNG *packet) { } else { // Allow reading from any memory address and length in special 'raw' mode. base = NULL; + // Boundary check against end of addressable space. + if (offset > 0) + count=MIN(count, -offset); } if (isok) { diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index 632fe88d1..9349ffd7c 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -186,6 +186,9 @@ static void UsbPacketReceived(uint8_t *packet) { } else { // Allow reading from any memory address and length in special 'raw' mode. base = NULL; + // Boundary check against end of addressable space. + if (offset > 0) + count=MIN(count, -offset); } if (isok) {