Fix heap out-of-bounds read in hf xerox view on short dump files

This commit is contained in:
Cole Munz committed 2026-08-30 15:39:45 -05:00
1 parent 6d2c35b05b
commit 18936b2188
2 files changed
+14

No files matched your search

+13
View File
@@ -952,6 +952,19 @@ static int CmdHFXeroxView(const char *Cmd) {
return res;
}
uint8_t info_max_block = 0;
for (uint8_t i = 0; i < ARRAYLEN(info_blocks); i++) {
if (info_blocks[i] > info_max_block) {
info_max_block = info_blocks[i];
}
}
size_t info_min = (info_max_block + 1) * XEROX_BLOCK_SIZE;
if (bytes_read < info_min) {
PrintAndLogEx(FAILED, "Error, dump file is too small to be a valid Xerox dump - bytes: %zu, expected at least: %zu", bytes_read, info_min);
free(dump);
return PM3_EFILE;
}
uint16_t blockno = bytes_read / XEROX_BLOCK_SIZE;
if (verbose) {