mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Each entry gets param_max_len bytes in the data table, and that's what the buffer is sized from - but nothing clamped what got written into it. For VT_UTF8 the length written was s_value.size()+1, and then a terminator was stored at data_ptr[param_len], one byte beyond that again. The memcpy already copies the terminator (param_len counts it), so that store was both redundant and always out of range. It doesn't take a malformed file to hit: several callers pass the string's own length as max_size - see PSPLoaders.cpp's TITLE, DISC_ID and DISC_VERSION - so the entry overran by two bytes every time, and a 128-character SAVEDATA_TITLE in a 128-byte slot wrote its terminator into the next entry's data. VT_UTF8_SPE had the same missing clamp without the off-by-one. Both are clamped now and log when they truncate, and a negative max_size no longer subtracts from the computed buffer size. Bytes written are unchanged for values that do fit, which is every normal case - the terminator now comes from the zero-fill instead of an explicit store - so this doesn't change any savedata the emulator produces. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9