From 5a828bd6a8d6a24a2e4ecc56a4f1870fcd5a5f8c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 29 Jan 2024 18:57:19 +0100 Subject: [PATCH] data diff now handles file sizes up to 4096 bytes --- CHANGELOG.md | 1 + client/src/cmddata.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 701038fbf..50ee0d9c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Changed `lf hitag dump --ns` - now support nosave flag (@iceman1001) - Added `hf xerox rdbl` - read block of a Fuji/Xerox tag (@iceman1001) - Added a xerox trace file, thanks @jeroenSteen, (@iceman1001) - Fixed `lf em 4x05 view` - now loads JSON files properl (@iceman1001) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 8b34add15..cfab0bb16 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -3132,10 +3132,13 @@ static int CmdDiff(const char *Cmd) { int res = PM3_SUCCESS; uint8_t *inA = NULL, *inB = NULL; size_t datalenA = 0, datalenB = 0; + + + // read file A if (fnlenA) { // read dump file - res = pm3_load_dump(filenameA, (void **)&inA, &datalenA, 2048); + res = pm3_load_dump(filenameA, (void **)&inA, &datalenA, MIFARE_4K_MAX_BYTES); if (res != PM3_SUCCESS) { return res; } @@ -3144,7 +3147,7 @@ static int CmdDiff(const char *Cmd) { // read file B if (fnlenB) { // read dump file - res = pm3_load_dump(filenameB, (void **)&inB, &datalenB, 2048); + res = pm3_load_dump(filenameB, (void **)&inB, &datalenB, MIFARE_4K_MAX_BYTES); if (res != PM3_SUCCESS) { return res; } @@ -3169,14 +3172,14 @@ static int CmdDiff(const char *Cmd) { // download emulator memory if (use_e) { - uint8_t *d = calloc(4096, sizeof(uint8_t)); + uint8_t *d = calloc(MIFARE_4K_MAX_BYTES, sizeof(uint8_t)); if (d == NULL) { PrintAndLogEx(WARNING, "Fail, cannot allocate memory"); return PM3_EMALLOC; } PrintAndLogEx(INFO, "downloading from emulator memory"); - if (GetFromDevice(BIG_BUF_EML, d, 4096, 0, NULL, 0, NULL, 2500, false) == false) { + if (GetFromDevice(BIG_BUF_EML, d, MIFARE_4K_MAX_BYTES, 0, NULL, 0, NULL, 2500, false) == false) { PrintAndLogEx(WARNING, "Fail, transfer from device time-out"); free(inA); free(inB); @@ -3185,10 +3188,10 @@ static int CmdDiff(const char *Cmd) { } if (fnlenA) { - datalenB = 4096; + datalenB = MIFARE_4K_MAX_BYTES; inB = d; } else { - datalenA = 4096; + datalenA = MIFARE_4K_MAX_BYTES; inA = d; } }