Skip to content

Commit f0c4855

Browse files
authored
fix hf search (#908)
* fix memory access violation in HF14B_Other_Reader()
1 parent fef3084 commit f0c4855

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

client/cmdhf14b.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int HF14BCmdRaw(bool reply, bool *crc, bool power, uint8_t *data, uint8_t *datal
121121
}
122122

123123
*datalen = ret;
124-
124+
125125
if (ret < 2) return 0;
126126

127127
memcpy(data, resp.d.asBytes, *datalen);
@@ -529,22 +529,21 @@ static bool HF14B_ST_Info(bool verbose) {
529529

530530

531531
// test for other 14b type tags (mimic another reader - don't have tags to identify)
532-
static bool HF14B_Other_Reader(bool verbose) {
533-
uint8_t data[4];
532+
static bool HF14B_Other_Reader(uint8_t *data, bool verbose) {
534533
uint8_t datalen;
535-
536534
bool crc = true;
537-
datalen = 4;
535+
538536
//std read cmd
539537
data[0] = 0x00;
540538
data[1] = 0x0b;
541539
data[2] = 0x3f;
542540
data[3] = 0x80;
541+
datalen = 4;
543542

544543
if (HF14BCmdRaw(true, &crc, true, data, &datalen, false) != 0) {
545544
if (datalen > 2 || !crc) {
546545
PrintAndLog ("\n14443-3b tag found:");
547-
PrintAndLog ("Unknown tag type answered to a 0x000b3f80 command ans:");
546+
PrintAndLog ("Unknown tag type answered to a 0x000b3f80 command:");
548547
PrintAndLog ("%s", sprint_hex(data, datalen));
549548
switch_off_field_14b();
550549
return true;
@@ -558,7 +557,7 @@ static bool HF14B_Other_Reader(bool verbose) {
558557
if (HF14BCmdRaw(true, &crc, true, data, &datalen, false) != 0) {
559558
if (datalen > 0) {
560559
PrintAndLog ("\n14443-3b tag found:");
561-
PrintAndLog ("Unknown tag type answered to a 0x0A command ans:");
560+
PrintAndLog ("Unknown tag type answered to a 0x0A command:");
562561
PrintAndLog ("%s", sprint_hex(data, datalen));
563562
switch_off_field_14b();
564563
return true;
@@ -572,7 +571,7 @@ static bool HF14B_Other_Reader(bool verbose) {
572571
if (HF14BCmdRaw(true, &crc, true, data, &datalen, false) != 0) {
573572
if (datalen > 0) {
574573
PrintAndLog ("\n14443-3b tag found:");
575-
PrintAndLog ("Unknown tag type answered to a 0x0C command ans:");
574+
PrintAndLog ("Unknown tag type answered to a 0x0C command:");
576575
PrintAndLog ("%s", sprint_hex(data, datalen));
577576
switch_off_field_14b();
578577
return true;
@@ -606,7 +605,7 @@ int infoHF14B(bool verbose) {
606605

607606
// try unknown 14b read commands (to be identified later)
608607
// could be read of calypso, CEPAS, moneo, or pico pass.
609-
if (HF14B_Other_Reader(verbose)) return 1;
608+
if (HF14B_Other_Reader(data, verbose)) return 1;
610609

611610
if (verbose) PrintAndLog("no 14443B tag found");
612611
return 0;
@@ -636,7 +635,7 @@ int readHF14B(bool verbose){
636635

637636
// try unknown 14b read commands (to be identified later)
638637
// could be read of calypso, CEPAS, moneo, or pico pass.
639-
if (HF14B_Other_Reader(verbose)) return 1;
638+
if (HF14B_Other_Reader(data, verbose)) return 1;
640639

641640
if (verbose) PrintAndLog("no 14443B tag found");
642641
return 0;

0 commit comments

Comments
 (0)