Fix heap out-of-bounds read in hf iclass view on short dump files
This commit is contained in:
1 parent
ab11f8f6a7
commit
2d45e334fb
2 files changed
+11
-1
No files matched your search
@@ -5306,7 +5306,10 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
|
||||
endblock = maxmemcount;
|
||||
|
||||
// remember endblock needs to relate to zero-index arrays.
|
||||
if (endblock > filemaxblock - 1)
|
||||
// filemaxblock is 0 when filesize < 8, so filemaxblock - 1 would underflow.
|
||||
if (filemaxblock == 0)
|
||||
endblock = 0;
|
||||
else if (endblock > filemaxblock - 1)
|
||||
endblock = filemaxblock - 1;
|
||||
|
||||
/*
|
||||
@@ -5515,6 +5518,12 @@ static int CmdHFiClassView(const char *Cmd) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (bytes_read < sizeof(picopass_hdr_t)) {
|
||||
PrintAndLogEx(FAILED, "Error, dump file is too small to be a valid iCLASS dump - bytes: %zu, expected at least: %zu", bytes_read, sizeof(picopass_hdr_t));
|
||||
free(dump);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "File size %zu bytes, file blocks %d (0x%x)", bytes_read, (uint16_t)(bytes_read >> 3), (uint16_t)(bytes_read >> 3));
|
||||
PrintAndLogEx(INFO, "Printing blocks from: " _YELLOW_("%02d") " to: " _YELLOW_("%02d"), (startblock == 0) ? 6 : startblock, endblock);
|
||||
|
||||
Reference in new issue
Block a user