1 Commits
Author SHA1 Message Date
Afonso JanuárioandKim Kulling 17ec36b247 Fix heap-buffer-overflow reading MD2 skin names (#6832)
* Fix heap-buffer-overflow reading MD2 skin names

The skin name field in an MD2 file is a fixed 64-byte buffer copied
straight from the file, with nothing guaranteeing it actually contains
a NUL terminator. If a malformed or crafted file fills those 64 bytes
with non-zero data right up against the end of the file, strlen() on
that field walks straight past the end of the read buffer looking for
a terminator that isn't there.

Bounded the scan with strnlen() capped at one less than the field's
size instead, the same approach MDCLoader already uses for its own
fixed-size name fields. Added a regression test with a hand-built MD2
file that reproduces the crash under ASan on the old code and imports
cleanly with the fix.

* Refactor MD2Loader.cpp for code clarity

---------

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2026-09-08 15:59:55 +02:00