[Bug 60000] New: msvcrt: fopen("wb, ccs=UTF-8") prepends a BOM unlike Windows
http://bugs.winehq.org/show_bug.cgi?id=60000 Bug ID: 60000 Summary: msvcrt: fopen("wb, ccs=UTF-8") prepends a BOM unlike Windows Product: Wine Version: 11.13 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@list.winehq.org Reporter: brandowlucas@gmail.com Target Milestone: --- Distribution: --- Created attachment 81407 --> http://bugs.winehq.org/attachment.cgi?id=81407 +msvcrt,+file I originally hit this in a fitgirl repack installer post-processing path. The affected program writes a binary intermediate file using: fopen(path, "wb, ccs=UTF-8") Wine prepends EF BB BF to the file even though the mode explicitly includes b. This shifts the binary stream and breaks its next consumer. I reduced it to a data-free CRT test, so the issue is not specific to that application. Reproducer: https://github.com/BrandowLucas/wine_msvcrt_binary_ccs_utf8_bom_reproducer That repository contains the source, prebuilt test executable, Windows/Wine logs, and the candidate patch I tested. Native Windows result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=4 hex=00002274 Unpatched Wine result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=7 hex=efbbbf00002274 Patched Wine result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=4 hex=00002274 The relevant Wine code is dlls/msvcrt/file.c:_wsopen_dispatch(). It writes utf8_bom whenever _O_U8TEXT is present, without accounting for _O_BINARY. The patch that made the reproducer match Windows locally is in the repo: https://github.com/BrandowLucas/wine_msvcrt_binary_ccs_utf8_bom_reproducer/b... It writes the UTF-8 BOM only for non-binary UTF-8 streams and adds a regression test. Validation after the patch: - msvcrt file test: 1120 tests, 0 failures - ucrtbase file test: 504 tests, 0 failures - clean probe output matches Windows Reference: fopen/_wfopen documentation, including b mapping to _O_BINARY: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfop... Possibly related bug: https://bugs.winehq.org/show_bug.cgi?id=38909 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60000 brandow <brandowlucas@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://github.com/BrandowL | |ucas/wine_msvcrt_binary_ccs | |_utf8_bom_reproducer Distribution|--- |ArchLinux Keywords| |download, patch, source -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60000 Piotr Caban <piotr.caban@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |a811297907f281b8ae53f99a5f4 | |c49de611ed050 Resolution|--- |FIXED CC| |piotr.caban@gmail.com --- Comment #1 from Piotr Caban <piotr.caban@gmail.com> --- The linked test works now. Marking as fixed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60000 --- Comment #2 from brandow <brandowlucas@gmail.com> --- I can confirm that the FitGirl Repack installer, which was the source of the original bug I encountered, has also been fixed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60000 Alexandre Julliard <julliard@winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #3 from Alexandre Julliard <julliard@winehq.org> --- Closing bugs fixed in 11.14. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla