[PATCH 0/1] MR4415: msvcrt: Pass INT_MAX as the length in implementations of the _mbscoll family.
A length of -1 has no special meaning for the mbsn*coll functions, and since it is > INT_MAX, it will eventually trigger _invalid_parameter in _strnicmp_l in newer versions of msvcrt. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4415
From: Tim Clem <tclem(a)codeweavers.com> A length of -1 has no special meaning for the mbsn*coll functions, and since it is > INT_MAX, it will eventually trigger _invalid_parameter in _strnicmp_l in newer versions of msvcrt. --- dlls/msvcrt/mbcs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 9b52170d4e9..385274a44a4 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -1118,7 +1118,7 @@ int CDECL _mbsnbicoll_l(const unsigned char *str1, const unsigned char *str2, si */ int CDECL _mbsicoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale) { - return _mbsnbicoll_l(str1, str2, -1, locale); + return _mbsnbicoll_l(str1, str2, INT_MAX, locale); } /********************************************************************* @@ -1138,7 +1138,7 @@ int CDECL _mbsicoll(const unsigned char* str, const unsigned char* cmp) return CompareStringA(get_mbcinfo()->mblcid, NORM_IGNORECASE, (const char*)str, -1, (const char*)cmp, -1)-CSTR_EQUAL; #else - return _mbsnbicoll_l(str, cmp, -1, NULL); + return _mbsnbicoll_l(str, cmp, INT_MAX, NULL); #endif } @@ -1164,7 +1164,7 @@ int CDECL _mbsnbcoll_l(const unsigned char *str1, const unsigned char *str2, siz */ int CDECL _mbscoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale) { - return _mbsnbcoll_l(str1, str2, -1, locale); + return _mbsnbcoll_l(str1, str2, INT_MAX, locale); } /********************************************************************* @@ -1184,7 +1184,7 @@ int CDECL _mbscoll(const unsigned char* str, const unsigned char* cmp) return CompareStringA(get_mbcinfo()->mblcid, 0, (const char*)str, -1, (const char*)cmp, -1)-CSTR_EQUAL; #else - return _mbsnbcoll_l(str, cmp, -1, NULL); + return _mbsnbcoll_l(str, cmp, INT_MAX, NULL); #endif } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4415
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4415
There's currently different limit of maximum string length depending on locale. It would be good to update parameters validation so it behaves in the same way no matter what locale is set. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4415#note_52700
participants (3)
-
Piotr Caban (@piotr) -
Tim Clem -
Tim Clem (@tclem)