[rtl]
authorAleksey Bragin <aleksey@reactos.org>
Tue, 13 Oct 2009 18:01:55 +0000 (18:01 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Tue, 13 Oct 2009 18:01:55 +0000 (18:01 +0000)
- Fix an out-of-bounds read in RtlpDidUnicodeToOemWorked.
See issue #4888 for more details.

svn path=/trunk/; revision=43438

reactos/lib/rtl/unicode.c

index c1f2358..bafe8c5 100644 (file)
@@ -417,12 +417,12 @@ RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString,
    ULONG i = 0;
 
    /* Go through all characters of a string */
-   while ((OemString->Buffer[i] != 0) &&
-          (i < OemString->Length))
+   while (i < OemString->Length)
    {
        /* Check if it got translated into '?', but source char
           wasn't '?' equivalent */
-       if ((OemString->Buffer[i] == NlsOemDefaultChar) &&
+       if ((OemString->Buffer[i] != 0) &&
+           (OemString->Buffer[i] == NlsOemDefaultChar) &&
            (UnicodeString->Buffer[i] != NlsUnicodeDefaultChar))
        {
            /* Yes, it means unmappable characters were found */