mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-01 05:07:03 +08:00
chg: 'mem load' added a max filesize check.
This commit is contained in:
parent
021c0a1349
commit
93d154f58c
1 changed files with 10 additions and 3 deletions
|
@ -9,7 +9,8 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "cmdflashmem.h"
|
#include "cmdflashmem.h"
|
||||||
|
|
||||||
#define FLASH_MEM_BLOCK_SIZE 256
|
#define FLASH_MEM_BLOCK_SIZE 256
|
||||||
|
#define FLASH_MEM_MAX_SIZE 0x3FFFF
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
@ -103,6 +104,12 @@ int CmdFlashMemLoad(const char *Cmd){
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fsize > FLASH_MEM_MAX_SIZE) {
|
||||||
|
PrintAndLogDevice(WARNING, "error, filesize is larger than available memory");
|
||||||
|
fclose(f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *dump = calloc(fsize, sizeof(uint8_t));
|
uint8_t *dump = calloc(fsize, sizeof(uint8_t));
|
||||||
if (!dump) {
|
if (!dump) {
|
||||||
|
@ -153,13 +160,13 @@ int CmdFlashMemSave(const char *Cmd){
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
uint32_t start_index = 0, len = 0x3FFFF;
|
uint32_t start_index = 0, len = FLASH_MEM_MAX_SIZE;
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
case 'h': return usage_flashmem_save();
|
case 'h': return usage_flashmem_save();
|
||||||
case 'l':
|
case 'l':
|
||||||
len = param_get32ex(Cmd, cmdp+1, 0x3FFFF, 10);
|
len = param_get32ex(Cmd, cmdp+1, FLASH_MEM_MAX_SIZE, 10);
|
||||||
cmdp += 2;
|
cmdp += 2;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|
Loading…
Reference in a new issue