From 0607f3a47b507cc5c1081fc8bef8639820ed3f32 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 15 Jan 2024 11:18:35 +0100 Subject: [PATCH] added some sanity checks for the person who enters too small blocksize --- client/src/cmdhf15.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 6ce5a2d67..27d432a2f 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1250,6 +1250,12 @@ static int CmdHF15ESave(const char *Cmd) { int count = arg_get_int_def(ctx, 3, -1); CLIParserFree(ctx); + // sanity checks + if (blocksize < 4) { + PrintAndLogEx(WARNING, "Blocksize too small, using default 4 bytes"); + blocksize = 4; + } + int bytes = CARD_MEMORY_SIZE; if (count > 0 && count * blocksize <= bytes) { bytes = count * blocksize; @@ -1703,6 +1709,11 @@ static int CmdHF15Dump(const char *Cmd) { return PM3_EINVARG; } + if (blocksize < 4) { + PrintAndLogEx(WARNING, "Blocksize too small, using default 4 bytes"); + blocksize = 4; + } + // default fallback to scan for tag. // overriding unaddress parameter :) if (uidlen != HF15_UID_LENGTH) { @@ -2054,6 +2065,11 @@ static int CmdHF15Readmulti(const char *Cmd) { return PM3_EINVARG; } + if (blocksize < 4) { + PrintAndLogEx(WARNING, "Blocksize too small, using default 4 bytes"); + blocksize = 4; + } + // enforcing add_option in order to get lock-info if (add_option == false) { if (verbose) { @@ -2201,6 +2217,11 @@ static int CmdHF15Readblock(const char *Cmd) { return PM3_EINVARG; } + if (blocksize < 4) { + PrintAndLogEx(WARNING, "Blocksize too small, using default 4 bytes"); + blocksize = 4; + } + // enforcing add_option in order to get lock-info if (add_option == false) { if (verbose) { @@ -2499,6 +2520,11 @@ static int CmdHF15Restore(const char *Cmd) { return PM3_EINVARG; } + if (blocksize < 4) { + PrintAndLogEx(WARNING, "Blocksize too small, using default 4 bytes"); + blocksize = 4; + } + // default fallback to scan for tag. // overriding unaddress parameter :) if (uidlen != HF15_UID_LENGTH) {