[PATCH 0/2] MR603: msvcp90: Use 'MultiByteToWideChar' instead of 'mbstowcs_s'.
'mbstowcs_s' will make a wrong path in non-ASCII environments. Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/603
From: YeshunYe <yeyeshun(a)uniontech.com> 'mbstowcs_s' will make a wrong path in non-ASCII environments. Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com> --- dlls/msvcp90/ios.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index ef2c122f17f..9b68226c8c0 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -3259,10 +3259,12 @@ FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot) FILE* __cdecl _Fiopen(const char *name, int mode, int prot) { wchar_t nameW[FILENAME_MAX]; - + int result; TRACE("(%s %d %d)\n", name, mode, prot); + result = MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, FILENAME_MAX-1); + nameW[result] = 0; - if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0) + if(result == 0) return NULL; return _Fiopen_wchar(nameW, mode, prot); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/603
From: YeshunYe <yeyeshun(a)uniontech.com> 'mbstowcs_s' will make a wrong path in non-ASCII environments. Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com> --- dlls/msvcp60/ios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/msvcp60/ios.c b/dlls/msvcp60/ios.c index 1fef80f8a43..59779b4df8d 100644 --- a/dlls/msvcp60/ios.c +++ b/dlls/msvcp60/ios.c @@ -26,6 +26,7 @@ #include "msvcp.h" #include "windef.h" #include "winbase.h" +#include "winnls.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcp); @@ -2125,10 +2126,13 @@ static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot) FILE* __cdecl ___Fiopen(const char *name, int mode) { wchar_t nameW[FILENAME_MAX]; + int result; TRACE("(%p %d)\n", name, mode); + result = MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, FILENAME_MAX-1); + nameW[result] = 0; - if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0) + if(result == 0) return NULL; return _Fiopen_wchar(nameW, mode, _SH_DENYNO); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/603
The behavior of the function changed at some point. I have written a quick&dirty test to demonstrate that ([0001-test.txt](/uploads/982da21ccf01cb089d613f184fd82faa/0001-test.txt)). It shows, that mbstowcs should be used in msvcp90. On the other hand it shouldn't be used in msvcp140. It will be needed to limit the change to only some versions of msvcpXX. It would be also nice to add some tests. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/603#note_5811
I think you are right, my patch is not accurate enough. I will think more and commit later. Thanks. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/603#note_5883
This merge request was closed by Yeshun Ye. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/603
participants (3)
-
Piotr Caban (@piotr) -
Yeshun Ye (@yeyeshun) -
YeshunYe