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") " -----------------------");
for (int i = 0; i < buflen; i++)
PrintAndLogEx(INFO, "AID: %06x ISO file id: %02x%02x ISO DF name[%d]: %s",
DesfireAIDByteToUint(&buf[i * 24]),
buf[i * 24 + 3], buf[i * 24 + 4],
strlen((char *)&buf[i * 24 + 5]),
&buf[i * 24 + 5]);
DesfireAIDByteToUint(&buf[i * 24 + 1]),
buf[i * 24 + 1 + 3], buf[i * 24 + 1 + 4],
strlen((char *)&buf[i * 24 + 1 + 5]),
&buf[i * 24 + 1 + 5]);
}
DropField();

View file

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