mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
coverity fixes
This commit is contained in:
parent
b7b42ebd39
commit
6da7fcd510
2 changed files with 46 additions and 10 deletions
|
@ -3776,6 +3776,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||||
}
|
}
|
||||||
case DICTIONARY: {
|
case DICTIONARY: {
|
||||||
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
||||||
|
free(data);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4447,6 +4448,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
|
||||||
}
|
}
|
||||||
case DICTIONARY: {
|
case DICTIONARY: {
|
||||||
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
||||||
|
free(data);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4886,7 +4888,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
|
||||||
|
|
||||||
//needs nt, ar, at, Data to decrypt
|
//needs nt, ar, at, Data to decrypt
|
||||||
static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "hf mf decrypt",
|
CLIParserInit(&ctx, "hf mf decrypt",
|
||||||
"Decrypt Crypto-1 encrypted bytes given some known state of crypto. See tracelog to gather needed values",
|
"Decrypt Crypto-1 encrypted bytes given some known state of crypto. See tracelog to gather needed values",
|
||||||
"hf mf decrypt --nt b830049b --ar 9248314a --at 9280e203 -d 41e586f9\n"
|
"hf mf decrypt --nt b830049b --ar 9248314a --at 9280e203 -d 41e586f9\n"
|
||||||
|
@ -4906,6 +4908,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
||||||
uint32_t nt = 0;
|
uint32_t nt = 0;
|
||||||
int res = arg_get_u32_hexstr_def(ctx, 1, 0, &nt);
|
int res = arg_get_u32_hexstr_def(ctx, 1, 0, &nt);
|
||||||
if (res != 1) {
|
if (res != 1) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
PrintAndLogEx(WARNING, "check `nt` parameter");
|
PrintAndLogEx(WARNING, "check `nt` parameter");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -4913,6 +4916,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
||||||
uint32_t ar_enc = 0;
|
uint32_t ar_enc = 0;
|
||||||
res = arg_get_u32_hexstr_def(ctx, 2, 0, &ar_enc);
|
res = arg_get_u32_hexstr_def(ctx, 2, 0, &ar_enc);
|
||||||
if (res != 1) {
|
if (res != 1) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
PrintAndLogEx(WARNING, "check `ar` parameter");
|
PrintAndLogEx(WARNING, "check `ar` parameter");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -4920,6 +4924,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
||||||
uint32_t at_enc = 0;
|
uint32_t at_enc = 0;
|
||||||
res = arg_get_u32_hexstr_def(ctx, 3, 0, &at_enc);
|
res = arg_get_u32_hexstr_def(ctx, 3, 0, &at_enc);
|
||||||
if (res != 1) {
|
if (res != 1) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
PrintAndLogEx(WARNING, "check `at` parameter");
|
PrintAndLogEx(WARNING, "check `at` parameter");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -5939,6 +5944,7 @@ static int CmdHF14AMfView(const char *Cmd) {
|
||||||
}
|
}
|
||||||
case DICTIONARY: {
|
case DICTIONARY: {
|
||||||
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
|
||||||
|
free(dump);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,12 +550,19 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||||
|
|
||||||
uint8_t key[6];
|
uint8_t key[6];
|
||||||
int keylen = 0;
|
int keylen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 8), key, sizeof(key), &keylen);
|
int res = CLIParamHexToBuf(arg_get_str(ctx, 8), key, sizeof(key), &keylen);
|
||||||
|
if (res != 0) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t nrar[8];
|
uint8_t nrar[8];
|
||||||
int nalen = 0;
|
int nalen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 9), nrar, sizeof(nrar), &nalen);
|
res = CLIParamHexToBuf(arg_get_str(ctx, 9), nrar, sizeof(nrar), &nalen);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
if (res != 0) {
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (keylen != 0 && keylen != 6) {
|
if (keylen != 0 && keylen != 6) {
|
||||||
|
@ -719,17 +726,30 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
||||||
|
|
||||||
uint8_t data[4];
|
uint8_t data[4];
|
||||||
int dlen = 0;
|
int dlen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 6), data, sizeof(data), &dlen);
|
int res = CLIParamHexToBuf(arg_get_str(ctx, 6), data, sizeof(data), &dlen);
|
||||||
|
if (res != 0) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t key[6];
|
uint8_t key[6];
|
||||||
int keylen = 0;
|
int keylen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 7), key, sizeof(key), &keylen);
|
res = CLIParamHexToBuf(arg_get_str(ctx, 7), key, sizeof(key), &keylen);
|
||||||
|
if (res != 0) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t nrar[8];
|
uint8_t nrar[8];
|
||||||
int nalen = 0;
|
int nalen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 8), nrar, sizeof(nrar), &nalen);
|
res = CLIParamHexToBuf(arg_get_str(ctx, 8), nrar, sizeof(nrar), &nalen);
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
if (res != 0) {
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (dlen != sizeof(data)) {
|
if (dlen != sizeof(data)) {
|
||||||
PrintAndLogEx(WARNING, "Wrong DATA len expected 4, got %d", dlen);
|
PrintAndLogEx(WARNING, "Wrong DATA len expected 4, got %d", dlen);
|
||||||
|
@ -814,17 +834,27 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
uint8_t filename[FILE_PATH_SIZE] = {0};
|
uint8_t filename[FILE_PATH_SIZE] = {0};
|
||||||
int fnlen = 0;
|
int fnlen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 1), filename, sizeof(filename), &fnlen);
|
int res = CLIParamHexToBuf(arg_get_str(ctx, 1), filename, sizeof(filename), &fnlen);
|
||||||
|
if (res != 0) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t key[6];
|
uint8_t key[6];
|
||||||
int keylen = 0;
|
int keylen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 2), key, sizeof(key), &keylen);
|
res = CLIParamHexToBuf(arg_get_str(ctx, 2), key, sizeof(key), &keylen);
|
||||||
|
if (res != 0) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t nrar[8];
|
uint8_t nrar[8];
|
||||||
int nalen = 0;
|
int nalen = 0;
|
||||||
CLIParamHexToBuf(arg_get_str(ctx, 3), nrar, sizeof(nrar), &nalen);
|
res = CLIParamHexToBuf(arg_get_str(ctx, 3), nrar, sizeof(nrar), &nalen);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
if (res != 0) {
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
PrintAndLogEx(WARNING, "to be implememted...");
|
PrintAndLogEx(WARNING, "to be implememted...");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue