mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-31 03:50:45 -07:00
apply fix for v3
This commit is contained in:
parent
b50b405128
commit
9835543a2f
1 changed files with 13 additions and 6 deletions
|
@ -1157,7 +1157,8 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
|||
uint8_t block[MFBLOCK_SIZE] = {0}; // ensure zero-filled when partial block of data read
|
||||
JsonLoadBufAsHex(root, blocks, block, MFBLOCK_SIZE, &len);
|
||||
if (!len) {
|
||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d has zero-length data ... file parsing stopped", ctype, i);
|
||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d has zero-length data", ctype, i);
|
||||
PrintAndLogEx(INFO, "file parsing stopped");
|
||||
break;
|
||||
} else if (len != MFBLOCK_SIZE) {
|
||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d only has %d bytes, expected %d (will fill with zero data)", ctype, i, len, MFBLOCK_SIZE);
|
||||
|
@ -1182,21 +1183,27 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
|||
*datalen = MFU_DUMP_PREFIX_LENGTH;
|
||||
|
||||
size_t sptr = 0;
|
||||
for (int i = 0; i < maxdatalen; i++) {
|
||||
|
||||
// load blocks (i) from 0..N, but check sptr against total data length, not `i`
|
||||
for (int i = 0; sptr < maxdatalen; i++) {
|
||||
if (sptr + MFBLOCK_SIZE > maxdatalen) {
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%4d (%04x) block (i)=%4d (%04x) sptr=%4d (%04x) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr);
|
||||
retval = PM3_EMALLOC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
snprintf(blocks, sizeof(blocks), "$.blocks.%d", i);
|
||||
uint8_t block[MFBLOCK_SIZE];
|
||||
uint8_t block[MFBLOCK_SIZE] = {0}; // ensure zero-filled when partial block of data read
|
||||
JsonLoadBufAsHex(root, blocks, block, MFBLOCK_SIZE, &len);
|
||||
if (!len)
|
||||
if (!len) {
|
||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d has zero-length data", ctype, i);
|
||||
PrintAndLogEx(INFO, "file parsing stopped");
|
||||
break;
|
||||
} else if (len != MFBLOCK_SIZE) {
|
||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d only has %d bytes, expected %d (will fill with zero data)", ctype, i, len, MFBLOCK_SIZE);
|
||||
}
|
||||
|
||||
memcpy(&udata.bytes[sptr], block, MFBLOCK_SIZE);
|
||||
sptr += len;
|
||||
sptr += MFBLOCK_SIZE; // always increment pointer by the full block size, even if only partial data read from dump file
|
||||
}
|
||||
|
||||
*datalen = sptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue