From f416fa9b4f933b22cbe15f904975b487fa6cd864 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 26 Apr 2020 12:56:19 +0200 Subject: [PATCH] cppchecker fixes --- armsrc/Standalone/hf_msdsal.c | 12 ++++++------ armsrc/hitag2crack.c | 4 +--- armsrc/lfsampling.h | 2 +- client/deps/amiitool/amiitool.c | 4 ++-- client/deps/jansson/pack_unpack.c | 2 +- client/src/cmdhf14a.c | 4 ++-- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/armsrc/Standalone/hf_msdsal.c b/armsrc/Standalone/hf_msdsal.c index 38416307c..9e3175ea8 100644 --- a/armsrc/Standalone/hf_msdsal.c +++ b/armsrc/Standalone/hf_msdsal.c @@ -371,9 +371,8 @@ void RunMod() { Dbhexdump(len, receivedCmd, false); if (receivedCmd[0] == 0x02 || receivedCmd[0] == 0x03) { //Emulate a Visa MSD(Magnetic stripe data) card - uint8_t ppsea[39] = {0x6F, 0x23, 0x84, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0xA5, 0x11, 0xBF, 0x0C, 0x0E, 0x61, 0x0C, 0x4F, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x87, 0x01, 0x01, 0x90, 0x00}; - uint8_t processing[10] = {0x80, 0x06, 0x00, 0x80, 0x08, 0x01, 0x01, 0x00, 0x90, 0x00}; - uint8_t visauid[34] = {0x6F, 0x1E, 0x84, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0xA5, 0x13, 0x50, 0x0B, 0x56, 0x49, 0x53, 0x41, 0x20, 0x43, 0x52, 0x45, 0x44, 0x49, 0x54, 0x9F, 0x38, 0x03, 0x9F, 0x66, 0x02, 0x90, 0x00}; + uint8_t processing_long[10] = {0x80, 0x06, 0x00, 0x80, 0x08, 0x01, 0x01, 0x00, 0x90, 0x00}; + uint8_t visauid_long[34] = {0x6F, 0x1E, 0x84, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0xA5, 0x13, 0x50, 0x0B, 0x56, 0x49, 0x53, 0x41, 0x20, 0x43, 0x52, 0x45, 0x44, 0x49, 0x54, 0x9F, 0x38, 0x03, 0x9F, 0x66, 0x02, 0x90, 0x00}; uint8_t last[4] = {0x70, 0x15, 0x57, 0x13}; uint8_t card[25]; @@ -389,16 +388,17 @@ void RunMod() { //Depending on card reader commands, the Proxmark will answer to fool the reader if (receivedCmd[2] == 0xA4 && receivedCmd[6] == 0x32 && prevCmd == 0) { //Respond with PPSE + uint8_t ppsea[39] = {0x6F, 0x23, 0x84, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0xA5, 0x11, 0xBF, 0x0C, 0x0E, 0x61, 0x0C, 0x4F, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x87, 0x01, 0x01, 0x90, 0x00}; memcpy(&dynamic_response_info.response[1], ppsea, sizeof(ppsea)); dynamic_response_info.response_n = sizeof(ppsea) + 1; prevCmd++; } else if (receivedCmd[2] == 0xA4 && receivedCmd[10] == 0x03 && receivedCmd[11] == 0x10 && prevCmd == 1) { //Respond Visa AID - memcpy(&dynamic_response_info.response[1], visauid, sizeof(visauid)); + memcpy(&dynamic_response_info.response[1], visauid_long, sizeof(visauid)); dynamic_response_info.response_n = sizeof(visauid) + 1; prevCmd++; } else if (receivedCmd[1] == 0x80 && receivedCmd[2] == 0xA8 && receivedCmd[6] == 0x83 && prevCmd == 2) { //GET PROCESSING - memcpy(&dynamic_response_info.response[1], processing, sizeof(processing)); - dynamic_response_info.response_n = sizeof(processing) + 1; + memcpy(&dynamic_response_info.response[1], processing_long, sizeof(processing)); + dynamic_response_info.response_n = sizeof(processing_long) + 1; prevCmd++; } else if (receivedCmd[1] == 0x00 && receivedCmd[2] == 0xB2 && prevCmd == 3) { //SFI memcpy(&dynamic_response_info.response[1], card, sizeof(card)); diff --git a/armsrc/hitag2crack.c b/armsrc/hitag2crack.c index 34d35ada6..faf530897 100644 --- a/armsrc/hitag2crack.c +++ b/armsrc/hitag2crack.c @@ -32,7 +32,7 @@ bool hitag2_crack(uint8_t *response, uint8_t *nrarhex) { uint8_t uid[32]; uint8_t nrar[64]; uint8_t e_firstcmd[10]; - uint8_t e_page0cmd[10]; +// uint8_t e_page0cmd[10]; uint8_t keybits[42]; uint8_t pagehex[9]; uint8_t temp[20]; @@ -298,7 +298,6 @@ bool hitag2crack_read_page(uint8_t *responsestr, uint8_t pagenum, uint8_t *nrar, uint8_t e_responsestr[9]; uint8_t e_response[32]; uint8_t response[32]; - int i; if (pagenum > 7) { UserMessage("hitag2crack_read_page:\r\n invalid pagenum\r\n"); @@ -354,7 +353,6 @@ bool hitag2crack_send_e_cmd(uint8_t *responsestr, uint8_t *nrar, uint8_t *cmd, i // uint8_t tmp[37]; uint8_t uid[9]; uint8_t e_page3str[9]; - int ret = 0; // get the UID if (!hitag2_get_uid(uid)) { diff --git a/armsrc/lfsampling.h b/armsrc/lfsampling.h index 570dc20fe..bad90d62c 100644 --- a/armsrc/lfsampling.h +++ b/armsrc/lfsampling.h @@ -82,7 +82,7 @@ uint32_t getSampleCounter(); * 0 or 95 ==> 125 kHz * **/ -void LFSetupFPGAForADC(int divisor, bool lf_field); +void LFSetupFPGAForADC(int divisor, bool reader_field); /** * Called from the USB-handler to set the sampling configuration diff --git a/client/deps/amiitool/amiitool.c b/client/deps/amiitool/amiitool.c index 2c5c4ddc2..b63222d50 100644 --- a/client/deps/amiitool/amiitool.c +++ b/client/deps/amiitool/amiitool.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) { return 1; } - nfc3d_amiibo_keys amiiboKeys; + nfc3d_amiibo_keys amiiboKeys = {0}; if (! LoadAmiikey(amiiboKeys, keyfile)) return 5; @@ -136,7 +136,7 @@ int main(int argc, char **argv) { return 3; } } - size_t readPages = fread(original, 4, NTAG215_SIZE / 4, f); + readPages = fread(original, 4, NTAG215_SIZE / 4, f); if (readPages < NFC3D_AMIIBO_SIZE / 4) { fprintf(stderr, "Could not read from save\n"); fclose(f); diff --git a/client/deps/jansson/pack_unpack.c b/client/deps/jansson/pack_unpack.c index 651e1c56b..279499ebd 100644 --- a/client/deps/jansson/pack_unpack.c +++ b/client/deps/jansson/pack_unpack.c @@ -185,7 +185,7 @@ static char *read_string(scanner_t *s, va_list *ap, length = va_arg(*ap, size_t); } else { prev_token(s); - length = s->has_error ? 0 : strlen(str); + length = s->has_error == 1 ? 0 : strlen(str); } if (!s->has_error && strbuffer_append_bytes(&strbuff, str, length) == -1) { diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index c53bc08b6..262e879f4 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1024,7 +1024,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) { active_select = true; break; case 'b': - sscanf(Cmd + i + 2, "%d", &temp); + sscanf(Cmd + i + 2, "%u", &temp); numbits = temp & 0xFFFF; i += 3; while (Cmd[i] != ' ' && Cmd[i] != '\0') { i++; } @@ -1032,7 +1032,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) { break; case 't': bTimeout = true; - sscanf(Cmd + i + 2, "%d", &temp); + sscanf(Cmd + i + 2, "%u", &temp); timeout = temp; i += 3; while (Cmd[i] != ' ' && Cmd[i] != '\0') { i++; }