Fixed a wrong length check in RtlAnsiStringToUnicodeString()/RtlOemStringToUnicodeStr...
authorHartmut Birr <osexpert@googlemail.com>
Mon, 1 Apr 2002 22:13:15 +0000 (22:13 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Mon, 1 Apr 2002 22:13:15 +0000 (22:13 +0000)
svn path=/trunk/; revision=2814

reactos/lib/ntdll/rtl/unicode.c
reactos/ntoskrnl/rtl/unicode.c

index 0e11932..8164585 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: unicode.c,v 1.19 2002/02/09 23:29:50 ekohl Exp $
+/* $Id: unicode.c,v 1.20 2002/04/01 22:13:15 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -14,6 +14,8 @@
 //#include <internal/nls.h>
 #include <ctype.h>
 #include <ntos/minmax.h>
+#define NDEBUG
+#include <ntdll/ntdll.h>
 
 /* FUNCTIONS *****************************************************************/
 
@@ -88,8 +90,11 @@ RtlAnsiStringToUnicodeString(
        }
        else
        {
-               if (Length >= DestinationString->MaximumLength)
+               if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
+               {
+                       DPRINT("STATUS_BUFFER_TOO_SMALL\n");
                        return STATUS_BUFFER_TOO_SMALL;
+               }
        }
        DestinationString->Length = Length;
 
@@ -988,8 +993,11 @@ RtlOemStringToUnicodeString (
        }
        else
        {
-               if (Length > DestinationString->MaximumLength)
+               if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
+               {
+                       DPRINT("STATUS_BUFFER_TOO_SMALL\n");
                        return STATUS_BUFFER_TOO_SMALL;
+               }
        }
        DestinationString->Length = Length;
 
index 1d9ad27..a4a528c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: unicode.c,v 1.20 2002/02/09 23:29:12 ekohl Exp $
+/* $Id: unicode.c,v 1.21 2002/04/01 22:13:15 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -88,8 +88,11 @@ RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
        }
        else
        {
-               if (Length > DestinationString->MaximumLength)
+               if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
+               {
+                       DPRINT("STATUS_BUFFER_TOO_SMALL\n");
                        return STATUS_BUFFER_TOO_SMALL;
+               }
        }
        DestinationString->Length = Length;
 
@@ -868,8 +871,11 @@ RtlOemStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
     }
   else
     {
-      if (Length >= DestinationString->MaximumLength)
+      if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
+      {
+       DPRINT("STATUS_BUFFER_TOO_SMALL\n");
        return STATUS_BUFFER_TOO_SMALL;
+      }
     }
   DestinationString->Length = Length;