Fixed a wrong length check in RtlAnsiStringToUnicodeString()/RtlOemStringToUnicodeString().

svn path=/trunk/; revision=2814
This commit is contained in:
Hartmut Birr 2002-04-01 22:13:15 +00:00
parent 0bdd211873
commit 9e6b238365
2 changed files with 20 additions and 6 deletions

View 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -14,6 +14,8 @@
//#include <internal/nls.h> //#include <internal/nls.h>
#include <ctype.h> #include <ctype.h>
#include <ntos/minmax.h> #include <ntos/minmax.h>
#define NDEBUG
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -88,9 +90,12 @@ RtlAnsiStringToUnicodeString(
} }
else else
{ {
if (Length >= DestinationString->MaximumLength) if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
{
DPRINT("STATUS_BUFFER_TOO_SMALL\n");
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
} }
}
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory (DestinationString->Buffer,
@ -988,9 +993,12 @@ RtlOemStringToUnicodeString (
} }
else else
{ {
if (Length > DestinationString->MaximumLength) if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
{
DPRINT("STATUS_BUFFER_TOO_SMALL\n");
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
} }
}
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory (DestinationString->Buffer,

View 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -88,9 +88,12 @@ RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
} }
else else
{ {
if (Length > DestinationString->MaximumLength) if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
{
DPRINT("STATUS_BUFFER_TOO_SMALL\n");
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
} }
}
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory (DestinationString->Buffer,
@ -868,9 +871,12 @@ RtlOemStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
} }
else else
{ {
if (Length >= DestinationString->MaximumLength) if (Length + sizeof(WCHAR) > DestinationString->MaximumLength)
{
DPRINT("STATUS_BUFFER_TOO_SMALL\n");
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
} }
}
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory (DestinationString->Buffer,