Conversation
The uncompressed KTX and DDS loaders, the compressed KTX loader and the .astc loader sized their allocation from header fields and only found out afterwards that the file did not hold that much data. The allocation is zero-filled, so a 68-byte KTX declaring 65535x65535 committed 4 GB of resident memory before failing, and the compressed KTX loader returned success with a truncated buffer. Every such site now compares the declared payload against the bytes left in the stream first and reports a corrupt header instead.
|
Is there any actual bug here? Either:
If yes, please provide specific reproducer data files.
This one sounds like it might be a functional bug, but I'm not entirely sure and can't reproduce it locally. It will fail if either reported data length is less than the required size for the declared number of blocks, or if the read fails to read the declared number of bytes, neither of which smells like a bug. |
|
You are right on the compressed KTX, and I have corrected the description. Every loader checks What remains is only the allocation itself: the zero-filled buffer is committed and touched before the read fails, so a 16-byte |
|
Closing - no user-visible bug. |
The uncompressed KTX and DDS loaders, the compressed KTX loader and the
.astcloader size an allocation from header fields and only discover afterwards that the file does not hold that much data. The allocation is zero-filled and touched, so a 16-byte.astcdeclaring 65535x65535 reaches 4.2 GB of resident memory and a 128-byte DDS declaring the same reaches 12 GB before the short read fails. (Corrected: an earlier version of this description claimed a compressed KTX could succeed with a truncated buffer; it cannot, every loader checks the read.)Each site now checks the declared payload against the bytes left in the stream before allocating, and reports a corrupt header. The ASAN caveat on
test_dl_corrupt_astc_huge_sizegoes with it.Verified with
/usr/bin/time -von the four files (4 to 6 MB peak after) and the x64 CI recipe.