Merge pull request #3409 from munzzyy/fix/em4x05-dump-corruption

Fix lf em 4x05 dump writing corrupted (byte-swapped) dump files
This commit is contained in:
Iceman authored and GitHub committed 2026-07-07 01:04:26 +07:00
commit ee8a5cca87
2 files changed
+10 -3

No files matched your search

+1
View File
@@ -4,6 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
- Fixed `lf em 4x05 dump` writing byte-swapped (corrupted) block data to the saved dump file (@munzzyy)
- Added `hf 14b dump` support for Standard ISO14443-B tags (@thisiscamk)
- Added `hf 14b ctrdbl` and `hf 14b ctdump` commands for interacting with ASK CTS tags (@kormax)
- Fixed `hf legic migrate` failing to parse the optional DCF argument as hex (@IdanHo)
+9 -3
View File
@@ -934,14 +934,20 @@ static void em4x05_print_footer(void) {
PrintAndLogEx(NORMAL, "");
}
static void em4x05_print_blocks(em_tech_type_t cardtype, uint8_t *data, uint8_t dlen) {
static void em4x05_print_blocks(em_tech_type_t cardtype, const uint8_t *src, uint8_t dlen) {
// must have 4 byte alignment
if ((data == NULL) || (dlen % EM4X05_BLOCK_SIZE) != 0) {
if ((src == NULL) || (dlen % EM4X05_BLOCK_SIZE) != 0) {
return;
}
uint32_t *d = (void *)data;
// Work on a private copy. This routine byte-swaps the buffer for display,
// and callers such as CmdEM4x05Dump() still need the original bytes
// afterwards to save an uncorrupted dump to file (issue #3403).
// dlen is a uint8_t, so 64 words is enough to hold any valid input.
uint32_t d[64] = {0};
memcpy(d, src, dlen);
uint8_t *data = (uint8_t *)d;
uint8_t i;
for (i = 0; i < (dlen >> 2); i++) {