cppcheck out-of-bounds

This commit is contained in:
iceman1001 2020-05-13 23:31:01 +02:00
commit 997567a9d6

View file

@ -238,7 +238,7 @@ int demodNexWatch(void) {
// output // output
PrintAndLogEx(SUCCESS, " NexWatch raw id : " _YELLOW_("0x%"PRIx32) , rawid); PrintAndLogEx(SUCCESS, " NexWatch raw id : " _YELLOW_("0x%"PRIx32) , rawid);
if (m_idx < 3) { if (m_idx < ARRAYLEN(items)) {
PrintAndLogEx(SUCCESS, " fingerprint : " _GREEN_("%s"), items[m_idx].desc); PrintAndLogEx(SUCCESS, " fingerprint : " _GREEN_("%s"), items[m_idx].desc);
} }
PrintAndLogEx(SUCCESS, " 88bit id : " _YELLOW_("%"PRIu32) " (" _YELLOW_("0x%"PRIx32)")", cn, cn); PrintAndLogEx(SUCCESS, " 88bit id : " _YELLOW_("%"PRIu32) " (" _YELLOW_("0x%"PRIx32)")", cn, cn);
@ -248,10 +248,10 @@ int demodNexWatch(void) {
} else { } else {
PrintAndLogEx(WARNING, " parity : %s (0x%X != 0x%X)", _RED_("fail"), parity, calc_parity); PrintAndLogEx(WARNING, " parity : %s (0x%X != 0x%X)", _RED_("fail"), parity, calc_parity);
} }
if (m_idx < 3) { if (m_idx < ARRAYLEN(items)) {
PrintAndLogEx(SUCCESS, " checksum : %s (0x%02X)", _GREEN_("ok"), chk); PrintAndLogEx(SUCCESS, " checksum : %s (0x%02X)", _GREEN_("ok"), chk);
} else { } else {
PrintAndLogEx(WARNING, " checksum : %s (0x%02X != 0x%02X)", _RED_("fail"), chk, items[m_idx].chk); PrintAndLogEx(WARNING, " checksum : %s (0x%02X)", _RED_("fail"), chk);
} }
PrintAndLogEx(INFO, " raw : " _YELLOW_("%"PRIX32"%"PRIX32"%"PRIX32), raw1, raw2, raw3); PrintAndLogEx(INFO, " raw : " _YELLOW_("%"PRIX32"%"PRIX32"%"PRIX32), raw1, raw2, raw3);
@ -360,7 +360,6 @@ static int CmdNexWatchSim(const char *Cmd) {
int rawlen = sizeof(rawhex); int rawlen = sizeof(rawhex);
uint8_t magic = 0xBE; uint8_t magic = 0xBE;
uint32_t cn = 0; uint32_t cn = 0;
uint8_t bs[128]; uint8_t bs[128];
memset(bs, 0, sizeof(bs)); memset(bs, 0, sizeof(bs));