splitbysize now put length of message at the first bytes of array's memory

This commit is contained in:
merlokk 2021-07-05 12:40:07 +03:00
commit 003a0b0de4
2 changed files with 24 additions and 10 deletions

View file

@ -5298,10 +5298,10 @@ static int CmdHF14ADesGetAppNames(const char *Cmd) {
PrintAndLogEx(INFO, "----------------------- " _CYAN_("File list") " -----------------------"); PrintAndLogEx(INFO, "----------------------- " _CYAN_("File list") " -----------------------");
for (int i = 0; i < buflen; i++) for (int i = 0; i < buflen; i++)
PrintAndLogEx(INFO, "AID: %06x ISO file id: %02x%02x ISO DF name[%d]: %s", PrintAndLogEx(INFO, "AID: %06x ISO file id: %02x%02x ISO DF name[%d]: %s",
DesfireAIDByteToUint(&buf[i * 24]), DesfireAIDByteToUint(&buf[i * 24 + 1]),
buf[i * 24 + 3], buf[i * 24 + 4], buf[i * 24 + 1 + 3], buf[i * 24 + 1 + 4],
strlen((char *)&buf[i * 24 + 5]), strlen((char *)&buf[i * 24 + 1 + 5]),
&buf[i * 24 + 5]); &buf[i * 24 + 1 + 5]);
} }
DropField(); DropField();

View file

@ -404,8 +404,14 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext *ctx, uint8
return res; return res;
} }
if (resp) if (resp) {
memcpy(resp, buf, buflen); if (splitbysize) {
resp[0] = buflen;
memcpy(&resp[1], buf, buflen);
} else {
memcpy(resp, buf, buflen);
}
}
if (respcode != NULL) if (respcode != NULL)
*respcode = rcode; *respcode = rcode;
@ -434,7 +440,8 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext *ctx, uint8
if (resp != NULL) { if (resp != NULL) {
if (splitbysize) { if (splitbysize) {
memcpy(&resp[i * splitbysize], buf, buflen); resp[i * splitbysize] = buflen;
memcpy(&resp[i * splitbysize + 1], buf, buflen);
i += 1; i += 1;
} else { } else {
memcpy(&resp[pos], buf, buflen); memcpy(&resp[pos], buf, buflen);
@ -480,8 +487,14 @@ static int DesfireExchangeISO(bool activate_field, DesfireContext *ctx, uint8_t
if (respcode != NULL && ((sw & 0xff00) == 0x9100)) if (respcode != NULL && ((sw & 0xff00) == 0x9100))
*respcode = sw & 0xff; *respcode = sw & 0xff;
if (resp) if (resp) {
memcpy(resp, buf, buflen); if (splitbysize) {
resp[0] = buflen;
memcpy(&resp[1], buf, buflen);
} else {
memcpy(resp, buf, buflen);
}
}
pos += buflen; pos += buflen;
if (!enable_chaining) { if (!enable_chaining) {
@ -512,7 +525,8 @@ static int DesfireExchangeISO(bool activate_field, DesfireContext *ctx, uint8_t
if (resp != NULL) { if (resp != NULL) {
if (splitbysize) { if (splitbysize) {
memcpy(&resp[i * splitbysize], buf, buflen); resp[i * splitbysize] = buflen;
memcpy(&resp[i * splitbysize + 1], buf, buflen);
i += 1; i += 1;
} else { } else {
memcpy(&resp[pos], buf, buflen); memcpy(&resp[pos], buf, buflen);