[Bug 59449] New: FormatMessageW fails for well-formed function call and crashes application
http://bugs.winehq.org/show_bug.cgi?id=59449 Bug ID: 59449 Summary: FormatMessageW fails for well-formed function call and crashes application Product: Wine Version: 11.1 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@list.winehq.org Reporter: and44more@gmail.com Distribution: --- Created attachment 80433 --> http://bugs.winehq.org/attachment.cgi?id=80433 C++ code to demonstrate it This isn't really a bug, but more a missing error message. The FormatMessageW (winbase.h) function fails if given the valid error code CRYPT_E_NO_MATCH as an argument (see attached code snippet). It returns 0 indicating an error and does not modify the lpBuffer pointer argument. Applications that assume that FormatMessageW will allocate the error message at the memory address lpBuffer is pointing to will crash (like in my case) if they initalized lpBuffer with 0 before. Technically, this is the fault of the application since it assumed that FormatMessageW will not return an error if given a well-formed function call, but wine is missing the error message in the first place and that should be fixed. I'd also like to propose setting lpBuffer to a pointer to an empty string (null character) instead of not modifying it when FormatMessageW fails. (Create a global empty string variable instead of allocating memory each time). This behavior would adhere to the FormatMessageW documentation and would make applications with missing error checks more fail safe in this case. I'm using linux mint 22.1 with wine 9.0, but I also tested the attached code snippet in linux arch with wine 11.1. -- 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=59449 Nikolay Sivov <bunglehead@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |8c38545dfe5d44315d3bd391f0d | |09f40da864360 Component|-unknown |kernel32 --- Comment #1 from Nikolay Sivov <bunglehead@gmail.com> --- The message for this particular error code has been added, commit 8c38545dfe5d44315d3bd391f0d09f40da864360. Thanks for the report. -- 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=59449 --- Comment #2 from bugfix44 <and44more@gmail.com> --- What about my proposal? In fact, CRYPT_E_NO_MATCH is not the only error message that's missing. All CRYPT_E_* messages seem to be missing (only tested a few just now). If I understand this correctly there is no complete error list maintained by windows so wine is predetermined to fail at uncommon error codes. In that case setting lpBuffer to a pointer to an empty string (while indicating that FormatMessageW failed) would be appropriate to avoid applications crashing that assume valid error codes give valid error messages. Any thoughts on my proposal? -- 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=59449 --- Comment #3 from Nikolay Sivov <bunglehead@gmail.com> --- (In reply to bugfix44 from comment #2)
What about my proposal?
In fact, CRYPT_E_NO_MATCH is not the only error message that's missing. All CRYPT_E_* messages seem to be missing (only tested a few just now). If I understand this correctly there is no complete error list maintained by windows so wine is predetermined to fail at uncommon error codes. In that case setting lpBuffer to a pointer to an empty string (while indicating that FormatMessageW failed) would be appropriate to avoid applications crashing that assume valid error codes give valid error messages. Any thoughts on my proposal?
It's not what it's doing on Windows, right? If you call with a code that has no assigned message, it will fail same as Wine. We can still add missing messages when there is a need for that. -- 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