Skip to content

fix(libc): reject invalid UTF-8 in wide formatting - #2109

Closed
STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/wide-format-encoding-errors
Closed

STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/wide-format-encoding-errors

Conversation

@STUPIDCONTEM

@STUPIDCONTEM STUPIDCONTEM commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Evidence review (2026-10-09)

Closed by maintainer; not ready to reopen. Required evidence: Title ID and a log showing malformed UTF-8 in wide formatting causes a real failure; stricter rejection may break working output.

Game/title ID: none verified. No PS5 title execution is claimed.

What

Reject malformed UTF-8 in narrow %s arguments to the guest wide formatter. The decoder previously copied invalid bytes or accepted overlong sequences, encoded surrogates and values above U+10FFFF. vswprintf and wprintf now return failure with guest EILSEQ (86); snwprintf_s handles the encoding error through its existing Annex K constraint-failure path. Remove the resolved encoding issue from TechnicalDebt while retaining the other secure-formatter limitations.

FreeBSD stable/11 vfwprintf.c treats failed multibyte %s conversion as an error. This retains the project's existing UTF-8 conversion policy and UTF-16 precision units. It does not change locale selection or wide %ls conversion.

Tested

Windows 10 Pro 19045, WinLibs GCC 15.2 UCRT posix SEH r7, Release, BUILD_TESTING=ON, main 6cc0503.

  • The added regression fails against unchanged upstream because an invalid UTF-8 %s conversion succeeds. After the fix, three focused runs pass for invalid lead/continuation bytes, overlong encodings, surrogates, out-of-range values and truncated sequences. All three affected entry points are exercised.
  • Valid Unicode boundaries and supplementary pairs pass. Zero precision does not inspect a nonterminated input; precision-limited conversion does not inspect later malformed bytes. Existing valid-string and width behavior remains covered.
  • With the separate build repair fix(build): declare SPIRV headers for Vulkan helper tests #2093, default and explicit libs builds passed and full CTest passed 494/494 in 34.85 seconds, with no skipped tests (stack 1db08171). The final PR additionally removes the resolved TechnicalDebt sentence; production and test files are identical to that tested version.
  • Parent reviewed exact open heads fix(libc): format guest wide strings in swprintf as 16-bit units #1511 (38e9c29) and fix(libc): format guest wide printf arguments on Linux #1804 (21d21da). These implement swprintf routing and narrow printf handling respectively, not this decoder correction. A local combined branch also includes fix(libc): translate asprintf encoding errors to guest errno #2094, preserves both external authors, resolves additive test/platform-guard conflicts and checks swprintf encoding failures. Default/libs builds and five relevant tests passed three times (a8f7f9fc0593d77689db29fb800b9625b6df66c6).

No Linux or title execution is claimed for this new correction. Conventions, whitespace and test registration checked before publication.

Checklist

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2153 docs/dev/TechnicalDebt.md L227
#2170 core/libs/prx/libc/src/FormattingWide.cpp L244

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: no title is shown passing malformed UTF-8 to these functions, and the change turns output that works on main into a -1 for any title that does. If a title stops on this, please reopen with its ID and the log line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants