From b7bd6ddadb4265f09b17b2d42faee1d9f32f3a23 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 30 Aug 2026 19:11:37 +0200 Subject: [PATCH] fix return value that break 'hf search', Thanks @atk! --- client/src/cmdhficlass.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 291d365d1..38eaba080 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -1814,7 +1814,7 @@ int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) { payload.flags |= FLAG_ICLASS_READER_SHALLOW_MOD; } - int res = PM3_SUCCESS; + int res = PM3_ETIMEOUT; do { clearCommandBuffer(); @@ -1823,14 +1823,19 @@ int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) { if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000)) { - iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes; - if (loop) { - if (resp.status == PM3_ERFTRANS) { + if (resp.status == PM3_ERFTRANS || resp.length < sizeof(iclass_card_select_resp_t)) { + if (loop) { continue; } - } else { + if (verbose) PrintAndLogEx(WARNING, "iCLASS / Picopass card select failed ( %d )", resp.status); + res = PM3_EOPABORTED; + break; + } - if (r->status == FLAG_ICLASS_NULL || resp.status == PM3_ERFTRANS) { + iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes; + if (loop == false) { + + if (r->status == FLAG_ICLASS_NULL) { if (verbose) PrintAndLogEx(WARNING, "iCLASS / Picopass card select failed ( %d , %d)", r->status, resp.status); res = PM3_EOPABORTED; break; @@ -1852,6 +1857,12 @@ int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) { free(card); res = PM3_SUCCESS; } + } else { + if (verbose) PrintAndLogEx(WARNING, "iCLASS / Picopass card select timeout"); + res = PM3_ETIMEOUT; + if (loop == false) { + break; + } } } while (loop && (kbd_enter_pressed() == false));