[Bug 42736] New: scanf doesn' t work as expected when using format string contains non-ascii chars
https://bugs.winehq.org/show_bug.cgi?id=42736 Bug ID: 42736 Summary: scanf doesn't work as expected when using format string contains non-ascii chars Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs(a)winehq.org Reporter: zhangboyang.id(a)gmail.com Distribution: --- Created attachment 57728 --> https://bugs.winehq.org/attachment.cgi?id=57728 working example, should link msvcrt.dll (e.g. use mingw to compile) (1) assume test.txt has this content hexdump -C test.txt 00000000 ef bb bf 68 65 6c 6c 6f |...hello| 00000008 // the content is UTF8 BOM + "hello" (2) fscanf(fp, "\xef\xbb\xbf") doesn't work as expected (using crossover 16.2.0) char s[1000]; fscanf(fp, "\xef\xbb\xbf"); ///// won't read utf-8 bom as expected fscanf(fp, "%s", s); /opt/cxoffice/bin/wine test.exe | hexdump -C 00000000 73 3d ef bb bf 68 65 6c 6c 6f 0d 0a |s=...hello..| 0000000c (3) expected behavior is (under windows) E:\winebug>test2 s=hello -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Zhang Boyang <zhangboyang.id(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zhangboyang.id(a)gmail.com -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Zhang Boyang <zhangboyang.id(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|zhangboyang.id(a)gmail.com | -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Zhang Boyang <zhangboyang.id(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zhangboyang.id(a)gmail.com -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Gijs Vermeulen <acescopezz(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |acescopezz(a)gmail.com --- Comment #1 from Gijs Vermeulen <acescopezz(a)gmail.com> --- Did this commit fix it: https://source.winehq.org/git/wine.git/commit/32bb8d9068ae5282b6b10734579aaa... -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |piotr.caban(a)gmail.com Resolution|--- |FIXED Fixed by SHA1| |32bb8d9068ae5282b6b10734579 | |aaa2d5195a5af --- Comment #2 from Piotr Caban <piotr.caban(a)gmail.com> --- The patch fixes attached application. 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 --- Comment #3 from Zhang Boyang <zhangboyang.id(a)gmail.com> --- Hello, I'm not sure whether directly casting '*format' to 'unsigned char' is appropriate. It seems that the wide-scanf and plain-scanf shares same code. If the code is compiled for wide-scanf, directly casting to 'unsigned char' may introduce new bug, e.g. ((unsigned char) L'\xabcd' == L'\xcd') is true. -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Resolution|FIXED |--- Status|RESOLVED |REOPENED --- Comment #4 from Piotr Caban <piotr.caban(a)gmail.com> --- You're right. Sorry for that. I'll send a fix. -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 --- Comment #5 from Gijs Vermeulen <acescopezz(a)gmail.com> --- (In reply to Zhang Boyang from comment #3)
Hello, I'm not sure whether directly casting '*format' to 'unsigned char' is appropriate. It seems that the wide-scanf and plain-scanf shares same code. If the code is compiled for wide-scanf, directly casting to 'unsigned char' may introduce new bug, e.g. ((unsigned char) L'\xabcd' == L'\xcd') is true.
Should be fixed with: https://source.winehq.org/git/wine.git/commitdiff/e7f9b562b9da5aa1fbe369f9e5... Can you confirm? -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 --- Comment #6 from Zhang Boyang <zhangboyang.id(a)gmail.com> --- Yes, I wrote another testcase, and the test is passed when using latest wine. I can confirm the bug is fixed. Thank you! -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 --- Comment #7 from Zhang Boyang <zhangboyang.id(a)gmail.com> --- Created attachment 57790 --> https://bugs.winehq.org/attachment.cgi?id=57790 another testcase, test both sscanf and swscanf. latest wine passed this testcase -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED Fixed by SHA1|32bb8d9068ae5282b6b10734579 |e7f9b562b9da5aa1fbe369f9e57 |aaa2d5195a5af |fe63d08cbb743 --- Comment #8 from Piotr Caban <piotr.caban(a)gmail.com> --- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #9 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 2.6. -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.0.x -- 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.
https://bugs.winehq.org/show_bug.cgi?id=42736 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|2.0.x |--- --- Comment #10 from Michael Stefaniuc <mstefani(a)winehq.org> --- Removing the 2.0.x milestone from bugs included in 2.0.2. -- 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)
-
wine-bugs@winehq.org