https://git.reactos.org/?p=reactos.git;a=commitdiff;h=49fcbe7cd8531178970ff…
commit 49fcbe7cd8531178970ffe48f91f3dc4d68022d1
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon May 17 16:14:26 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed May 19 22:50:29 2021 +0200
[RTL] Fix RtlIsValidOemCharacter implementation for Multibyte code pages
CORE-17571
---
sdk/lib/rtl/unicode.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c
index 7f045401326..e1896497ce6 100644
--- a/sdk/lib/rtl/unicode.c
+++ b/sdk/lib/rtl/unicode.c
@@ -519,16 +519,24 @@ RtlIsValidOemCharacter(IN PWCHAR Char)
/* If multi-byte code page present */
if (NlsMbOemCodePageTag)
{
- USHORT Offset = 0;
+ USHORT Offset;
OemChar = NlsUnicodeToMbOemTable[*Char];
/* If character has Lead Byte */
- if (NlsOemLeadByteInfo[HIBYTE(OemChar)])
- Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
+ Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
+ if (Offset)
+ {
+ /* Use DBCS table */
+ UnicodeChar = NlsOemLeadByteInfo[Offset + LOBYTE(OemChar)];
+ }
+ else
+ {
+ UnicodeChar = NlsOemToUnicodeTable[OemChar];
+ }
- /* Receive Unicode character from the table */
- UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) +
Offset]);
+ /* Upcase */
+ UnicodeChar = RtlpUpcaseUnicodeChar(UnicodeChar);
/* Receive OEM character from the table */
OemChar = NlsUnicodeToMbOemTable[UnicodeChar];
@@ -544,7 +552,10 @@ RtlIsValidOemCharacter(IN PWCHAR Char)
/* Not valid character, failed */
if (OemChar == NlsOemDefaultChar)
+ {
+ DPRINT1("\\u%04x is not valid for OEM\n", *Char);
return FALSE;
+ }
*Char = UnicodeChar;