various minor fixes

svn path=/trunk/; revision=18941
This commit is contained in:
Thomas Bluemel 2005-11-01 22:45:35 +00:00
parent 837e60ee47
commit 3cda2939fe

View file

@ -69,6 +69,8 @@ RtlAnsiStringToUnicodeString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlAnsiStringToUnicodeSize(AnsiSource); Length = RtlAnsiStringToUnicodeSize(AnsiSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
UniDest->Length = (USHORT)Length - sizeof(WCHAR); UniDest->Length = (USHORT)Length - sizeof(WCHAR);
@ -350,10 +352,11 @@ VOID
NTAPI NTAPI
RtlFreeAnsiString(IN PANSI_STRING AnsiString) RtlFreeAnsiString(IN PANSI_STRING AnsiString)
{ {
PAGED_CODE_RTL();
if (AnsiString->Buffer) if (AnsiString->Buffer)
{ {
RtlpFreeStringMemory(AnsiString->Buffer, TAG_ASTR); RtlpFreeStringMemory(AnsiString->Buffer, TAG_ASTR);
RtlZeroMemory(AnsiString, sizeof(ANSI_STRING));
} }
} }
@ -364,7 +367,12 @@ VOID
NTAPI NTAPI
RtlFreeOemString(IN POEM_STRING OemString) RtlFreeOemString(IN POEM_STRING OemString)
{ {
if (OemString->Buffer) RtlpFreeStringMemory(OemString->Buffer, TAG_OSTR); PAGED_CODE_RTL();
if (OemString->Buffer)
{
RtlpFreeStringMemory(OemString->Buffer, TAG_OSTR);
}
} }
/* /*
@ -374,10 +382,11 @@ VOID
NTAPI NTAPI
RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
{ {
PAGED_CODE_RTL();
if (UnicodeString->Buffer) if (UnicodeString->Buffer)
{ {
RtlpFreeStringMemory(UnicodeString->Buffer, TAG_ASTR); RtlpFreeStringMemory(UnicodeString->Buffer, TAG_ASTR);
RtlZeroMemory(UnicodeString, sizeof(UNICODE_STRING));
} }
} }
@ -476,7 +485,7 @@ RtlInitUnicodeStringEx(OUT PUNICODE_STRING DestinationString,
if(SourceString) if(SourceString)
{ {
DestSize = wcslen(SourceString) * sizeof(WCHAR); DestSize = wcslen(SourceString) * sizeof(WCHAR);
if (DestSize > 0xFFFC) return STATUS_NAME_TOO_LONG; if (DestSize > 0xFFFE) return STATUS_NAME_TOO_LONG;
DestinationString->Length = (USHORT)DestSize; DestinationString->Length = (USHORT)DestSize;
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR); DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
} }
@ -905,6 +914,8 @@ RtlUnicodeStringToAnsiString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToAnsiSize(UniSource); Length = RtlUnicodeStringToAnsiSize(UniSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
@ -958,6 +969,8 @@ RtlOemStringToUnicodeString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlOemStringToUnicodeSize(OemSource); Length = RtlOemStringToUnicodeSize(OemSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
@ -1008,6 +1021,8 @@ RtlUnicodeStringToOemString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToOemSize(UniSource); Length = RtlUnicodeStringToOemSize(UniSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
@ -1119,6 +1134,8 @@ RtlOemStringToCountedUnicodeString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlOemStringToCountedUnicodeSize(OemSource); Length = RtlOemStringToCountedUnicodeSize(OemSource);
if (!Length) if (!Length)
@ -1427,6 +1444,8 @@ RtlUnicodeStringToCountedOemString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToCountedOemSize(UniSource); Length = RtlUnicodeStringToCountedOemSize(UniSource);
if (!Length) if (!Length)
@ -1532,6 +1551,8 @@ RtlUpcaseUnicodeString(
{ {
ULONG i, j; ULONG i, j;
PAGED_CODE_RTL();
if (AllocateDestinationString == TRUE) if (AllocateDestinationString == TRUE)
{ {
UniDest->MaximumLength = UniSource->Length; UniDest->MaximumLength = UniSource->Length;
@ -1572,6 +1593,8 @@ RtlUpcaseUnicodeStringToAnsiString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToAnsiSize(UniSource); Length = RtlUnicodeStringToAnsiSize(UniSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
@ -1623,6 +1646,8 @@ RtlUpcaseUnicodeStringToCountedOemString(
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToCountedOemSize(UniSource); Length = RtlUnicodeStringToCountedOemSize(UniSource);
if (!Length) if (!Length)
@ -1680,6 +1705,8 @@ RtlUpcaseUnicodeStringToOemString (
ULONG Length; ULONG Length;
ULONG Index; ULONG Index;
PAGED_CODE_RTL();
Length = RtlUnicodeStringToOemSize(UniSource); Length = RtlUnicodeStringToOemSize(UniSource);
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
@ -1914,7 +1941,11 @@ RtlCreateUnicodeString(
{ {
ULONG Length; ULONG Length;
PAGED_CODE_RTL();
Length = (wcslen(Source) + 1) * sizeof(WCHAR); Length = (wcslen(Source) + 1) * sizeof(WCHAR);
if (Length > 0xFFFE) return FALSE;
UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
if (UniDest->Buffer == NULL) return FALSE; if (UniDest->Buffer == NULL) return FALSE;
@ -1965,6 +1996,8 @@ RtlDowncaseUnicodeString(
ULONG i; ULONG i;
ULONG StopGap; ULONG StopGap;
PAGED_CODE_RTL();
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
UniDest->MaximumLength = UniSource->Length; UniDest->MaximumLength = UniSource->Length;
@ -2108,6 +2141,8 @@ RtlDuplicateUnicodeString(
IN PCUNICODE_STRING SourceString, IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString) OUT PUNICODE_STRING DestinationString)
{ {
PAGED_CODE_RTL();
if (SourceString == NULL || DestinationString == NULL) if (SourceString == NULL || DestinationString == NULL)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;