fix several coverity findings

This commit is contained in:
iceman1001 committed 2026-07-02 16:48:17 +02:00
1 parent 344e7de9a1
commit 6c3e3c7a44
5 files changed
+24 -41

No files matched your search

+3 -4
View File
@@ -702,22 +702,21 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {
uint8_t rx[HITAG_FRAME_LEN] = { 0x00 };
uint8_t tx[HITAG_FRAME_LEN] = { 0x00 };
lf_hts_read_response_t card = {0};
int status = PM3_SUCCESS, reason = -1;
reason = hts_select_tag(payload, tx, ARRAYLEN(tx), rx, ARRAYLEN(rx), HITAG_T_WAIT_FIRST, ledcontrol);
int status = PM3_SUCCESS;
int reason = hts_select_tag(payload, tx, ARRAYLEN(tx), rx, ARRAYLEN(rx), HITAG_T_WAIT_FIRST, ledcontrol);
if (reason != 0) {
status = PM3_ERFTRANS;
goto read_end;
}
if (payload->page >= tag.max_page) {
DBG Dbprintf("Warning, read page "_YELLOW_("%d") " > max page("_YELLOW_("%d") ") ", payload->page, tag.max_page);
}
int page_addr = payload->page;
int page_index = 0;
lf_hts_read_response_t card = {0};
memcpy(card.config_page.asBytes, tag.data.pages[HITAGS_CONFIG_PADR], HITAGS_PAGE_SIZE);
+6 -3
View File
@@ -693,10 +693,15 @@ exit:
* Reads a Hitag µ tag
*/
void htu_read(const lf_hitag_data_t *payload, bool ledcontrol) {
size_t rxlen = 0;
uint8_t rx[HITAG_FRAME_LEN] = {0x00};
size_t txlen = 0;
uint8_t tx[HITAG_FRAME_LEN] = {0x00};
lf_htu_read_response_t card = {0};
int status = PM3_SUCCESS;
// DBG {
@@ -719,9 +724,7 @@ void htu_read(const lf_hitag_data_t *payload, bool ledcontrol) {
goto exit;
}
lf_htu_read_response_t card = {
.icr = tag.icr,
};
card.icr = tag.icr;
memcpy(card.uid, tag.uid, HITAGU_UID_SIZE);
memcpy(card.config_page.asBytes, tag.config.asBytes, HITAGU_BLOCK_SIZE);
-13
View File
@@ -494,8 +494,6 @@ int16_t I2C_BufferRead(uint8_t *data, uint16_t len, uint8_t device_cmd, uint8_t
return 0;
}
// uint8_t *pd = data;
// extra wait 500us (514us measured)
// 200us (xx measured)
WaitUS(600);
@@ -592,13 +590,6 @@ int16_t I2C_BufferRead(uint8_t *data, uint16_t len, uint8_t device_cmd, uint8_t
I2C_Stop();
// Dbprintf("rec len... %u readcount... %u", recv_len, readcount);
// Dbhexdump(readcount, pd, false);
if (readcount < 2) {
return 0;
}
// return bytecount - bytes encoding length
return readcount - 2;
}
@@ -769,10 +760,6 @@ bool sc_rx_bytes(uint8_t *dest, uint16_t *destlen, uint32_t wait) {
}
}
if (len < 1) {
return false;
}
*destlen = len;
return true;
}
+3 -15
View File
@@ -201,31 +201,19 @@ int CmdSmartRaw(const uint8_t prepend, const uint8_t *data, int dlen, uint8_t *o
payload->len = dlen;
memcpy(payload->data, data, dlen);
payload->flags = SC_LOG;
bool active = true;
bool active_select = false;
int timeout = 600;
bool use_t0 = true;
if (active || active_select) {
payload->flags |= (SC_CONNECT | SC_CLEARLOG);
if (active_select)
payload->flags |= SC_SELECT;
}
payload->flags = ( SC_LOG | SC_CONNECT | SC_CLEARLOG );
payload->wait_delay = 0;
if (timeout > -1) {
payload->flags |= SC_WAIT;
payload->wait_delay = timeout;
}
if (dlen > 0) {
if (use_t0)
payload->flags |= SC_RAW_T0;
else
payload->flags |= SC_RAW;
payload->flags |= SC_RAW_T0;
}
SmartCardDirectSend(prepend, payload, output, olen, 0);
return PM3_SUCCESS;
+12 -6
View File
@@ -1663,8 +1663,9 @@ void iClass_Authentication_fast(iclass_chk_t *p) {
uint8_t resp[ICLASS_BUFFER_SIZE] = {0};
uint8_t readcheck_cc[] = { 0x80 | ICLASS_CMD_READCHECK, 0x02 };
if (p->use_credit_key)
if (p->use_credit_key) {
readcheck_cc[0] = 0x10 | ICLASS_CMD_READCHECK;
}
// select card / e-purse
picopass_hdr_t hdr = {0};
@@ -1678,10 +1679,13 @@ void iClass_Authentication_fast(iclass_chk_t *p) {
Iso15693InitReader();
bool isOK = false;
uint8_t i = 0;
uint32_t start_time = 0;
uint32_t eof_time = 0;
uint32_t start_time = 0, eof_time = 0;
if (select_iclass_tag(&hdr, p->use_credit_key, &eof_time, shallow_mod) == false)
if (select_iclass_tag(&hdr, p->use_credit_key, &eof_time, shallow_mod) == false) {
goto out;
}
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
@@ -1689,12 +1693,13 @@ void iClass_Authentication_fast(iclass_chk_t *p) {
uint16_t checked = 0;
// Keychunk loop
uint8_t i = 0;
for (i = 0; i < p->count; i++) {
// Allow button press / usb cmd to interrupt device
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) goto out;
if (BUTTON_PRESS() || data_available()) {
goto out;
}
checked = 0;
}
++checked;
@@ -1710,8 +1715,9 @@ void iClass_Authentication_fast(iclass_chk_t *p) {
// expect 4bytes, 3 retries times..
isOK = iclass_send_cmd_with_retries(check, sizeof(check), resp, sizeof(resp), 4, 2, &start_time, ICLASS_READER_TIMEOUT_OTHERS, &eof_time, shallow_mod);
if (isOK)
if (isOK) {
goto out;
}
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
// Auth Sequence MUST begin with reading e-purse. (block2)