Skip to content

fix out-of-bounds write in store_dds_uncompressed_image for 3d ldr#643

Merged
solidpixel merged 3 commits into
ARM-software:mainfrom
sahvx655-wq:dds-store-plane-stride
Jun 13, 2026
Merged

fix out-of-bounds write in store_dds_uncompressed_image for 3d ldr#643
solidpixel merged 3 commits into
ARM-software:mainfrom
sahvx655-wq:dds-store-plane-stride

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

While checking the uncompressed DDS writer against the KTX one I noticed the LDR plane pointer in store_dds_uncompressed_image is advanced by dim_y * dim_z * image_components per slice, where a plane is actually dim_x * dim_y * image_components. The 16-bit branch in the same function, and both branches of the KTX writer, use dim_x, so this is a stray dim_z. For any 3D image whose depth is larger than its width the per-slice base pointer lands past the end of the pixel_data8 buffer and the scanline copy then writes over the heap. It is reachable when decoding a 3D LDR .astc straight to .dds, or when saving a 3D image array as .dds.

AddressSanitizer reports a heap write one byte past the pixel buffer on a 4x4x8 LDR image, traced back to this slice loop; with the stray dim_z swapped back to dim_x every plane pointer sits inside the buffer and the writer round-trips cleanly. The bound belongs in the writer because the buffer being indexed is the one this function allocates from the same dimensions, so a caller has no way to correct a stride computed internally.

solidpixel
solidpixel previously approved these changes Jun 13, 2026
@solidpixel solidpixel merged commit 4648fb9 into ARM-software:main Jun 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants