[WINESYNC] kernel32: Check for invalid flags in codepage conversion functions.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 0b95ebd283986fa179c7ec6d2ea3f34c977c3aaf by Alex Henrie <alexhenrie24@gmail.com>
This commit is contained in:
winesync 2024-04-25 19:55:05 +03:00 committed by Timo Kreuzer
parent 544f114459
commit 535fffd824

View file

@ -56,6 +56,9 @@ extern HMODULE kernel32_handle;
#define LOCALE_LOCALEINFOFLAGSMASK (LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP|\
LOCALE_RETURN_NUMBER|LOCALE_RETURN_GENITIVE_NAMES)
#define MB_FLAGSMASK (MB_PRECOMPOSED|MB_COMPOSITE|MB_USEGLYPHCHARS|MB_ERR_INVALID_CHARS)
#define WC_FLAGSMASK (WC_DISCARDNS|WC_SEPCHARS|WC_DEFAULTCHAR|WC_ERR_INVALID_CHARS|\
WC_COMPOSITECHECK|WC_NO_BEST_FIT_CHARS)
static const WCHAR szLocaleKeyName[] = {
'\\', 'R', 'e', 'g', 'i', 's', 't', 'r', 'y', '\\',
@ -2501,6 +2504,11 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
#endif
/* fall through */
case CP_UTF8:
if (flags & ~MB_FLAGSMASK)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = wine_utf8_mbstowcs( flags, src, srclen, dst, dstlen );
break;
default:
@ -2509,6 +2517,11 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (flags & ~MB_FLAGSMASK)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = wine_cp_mbstowcs( table, flags, src, srclen, dst, dstlen );
break;
}
@ -2732,6 +2745,11 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (flags & ~WC_FLAGSMASK)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = wine_utf8_wcstombs( flags, src, srclen, dst, dstlen );
break;
default:
@ -2740,6 +2758,11 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (flags & ~WC_FLAGSMASK)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = wine_cp_wcstombs( table, flags, src, srclen, dst, dstlen,
defchar, used ? &used_tmp : NULL );
if (used) *used = used_tmp;