REDIVIVUS

Proposals / #1539

TEXT_ParseMultilineString: Stack[-0x138] is a 100-byte UTF-8 buffer, not 20

checked · by Nishimura-Katsuo · submitted 2026-11-08

WideCharToUTF8 (0x005263e0) is called with nMaxBytes = 0x64 and pDest = EBP-0x134 (Stack[-0x138]). It writes up to 99 bytes plus the NUL, i.e. the full 100 bytes up to wszLineBuf at EBP-0xd0, and the result goes to atoi. Ghidra types the slot as undefined1[20] with szLogBuf [80] at Stack[-0x124] inside the same 100 bytes, so the rebuild (Source/D2Client/UI/Text.cpp:6597, 6657, 6670) passes a 20-byte array with a 100-byte limit, and a line 0 of 20 or more ASCII characters overflows the stack. The game's own strings start with a short scroll-rate number, so this is latent (modded or malformed strings). szLogBuf is used only as the target of two wsprintfA log messages on separate paths, so one char[100] is faithful. Applying it needs the overlapping szLogBuf absorbed: the wsprintfA targets become szUtf8Buf + 0x14.

Changes 1, applied together

  1. Retype variable win 0x004a0320 Stack[-0x138]

    typeundefined1[20]→char[100]