Skip to content

1/15 wsprintfA: cap output and width, consume unhandled args - #2

Open
avanturist888 wants to merge 1 commit into
evmar:mainfrom
avanturist888:slice/wsprintfa
Open

1/15 wsprintfA: cap output and width, consume unhandled args#2
avanturist888 wants to merge 1 commit into
evmar:mainfrom
avanturist888:slice/wsprintfa

Conversation

@avanturist888

Copy link
Copy Markdown
Contributor

Three bugs in wsprintfA, which came in with my earlier commit, so these are mine to fix:

  • No output cap. The real one writes at most 1024 characters including the nul, and callers size their buffers for that; this wrote however much the format produced, so a long %s runs past the caller's buffer into whatever follows it.
  • The field width is parsed unbounded into a usize that then sizes an allocation here, so %2000000000d asks for 2GB of padding, and width * 10 overflows on a long enough digit run.
  • An unhandled specifier printed %f but did not consume its argument, so every argument after it read the wrong stack slot. wsprintfA(buf, "%f fps in %s", flt, name) makes %s treat the float's low dword as a pointer.

First of the small PRs replacing #1, per the discussion there.

@avanturist888 avanturist888 changed the title wsprintfA: cap output and width, consume unhandled args 1/15 wsprintfA: cap output and width, consume unhandled args Aug 19, 2026
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.

1 participant