mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
map_read sized chd->map as sizeof(map_entry) * totalhunks straight from the header. With a 32-bit size_t the product wraps (0x0CCCCCCD hunks of the 20-byte i386 entry allocate 4 bytes), and the extraction loop then writes a full 512-entry chunk past the end of the buffer. The map follows the header as one record per hunk plus the end-of-list cookie, so the file size now bounds the count, and the count must also keep the allocation inside size_t; either failure is CHDERR_INVALID_DATA before anything is allocated. Regression lane chd_map_alloc_test opens v3/v4 images from memory, including both wrapping counts with a full map chunk present.