fix 'hf 15 csetuid'

* don't break when tag doesn't respond to magic commands
This commit is contained in:
pwpiwi 2019-12-04 19:29:10 +01:00
commit dcf63ca057
2 changed files with 16 additions and 9 deletions

View file

@ -1854,10 +1854,10 @@ void SetTag15693Uid(uint8_t *uid) {
DbdecodeIso15693Answer(recvlen, recvbuf); DbdecodeIso15693Answer(recvlen, recvbuf);
} }
} }
// Note: need to know if we expect an answer from one of the magic commands
if (recvlen <= 0) { // if (recvlen < 0) {
break; // break;
} // }
} }
cmd_send(CMD_ACK, recvlen, 0, 0, NULL, 0); cmd_send(CMD_ACK, recvlen, 0, 0, NULL, 0);

View file

@ -984,17 +984,24 @@ static int CmdHF15CSetUID(const char *Cmd) {
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
int recv_len = resp.arg[0]; int recv_len = resp.arg[0];
uint8_t *recv = resp.d.asBytes;
if (recv_len == 0) { if (recv_len == 0) {
PrintAndLog("received SOF only. Maybe Picopass/iCLASS?"); PrintAndLog("Received SOF only. Maybe Picopass/iCLASS?");
} else if (recv_len == -1) { } else if (recv_len == -1) {
PrintAndLog("card didn't respond"); PrintAndLog("Tag didn't respond");
} else if (recv_len == -2) { } else if (recv_len == -2) {
PrintAndLog("receive buffer overflow"); PrintAndLog("Receive buffer overflow");
} else if (ISO15693_CRC_CHECK != Crc(recv, recv_len)) {
PrintAndLog("CRC check failed on Tag response");
} else if (!(recv[0] & ISO15693_RES_ERROR)) {
PrintAndLog("Tag returned OK");
} else {
PrintAndLog("Tag returned Error %i: %s", recv[1], TagErrorStr(recv[1]));
} }
} else { } else {
PrintAndLog("timeout while waiting for reply."); PrintAndLog("No answer from Proxmark");
} }
if (!getUID(newUid)) { if (!getUID(newUid)) {