Fix FsRtlDissectName(). Pierre Schweitzer.

svn path=/trunk/; revision=42722
This commit is contained in:
Dmitry Gorbachev 2009-08-16 01:20:15 +00:00
parent bc80314293
commit 961afecdd8

View file

@ -142,6 +142,10 @@ FsRtlDissectName(IN UNICODE_STRING Name,
ULONG FirstPosition, i; ULONG FirstPosition, i;
ULONG SkipFirstSlash = 0; ULONG SkipFirstSlash = 0;
/* Zero the strings before continuing */
RtlZeroMemory(FirstPart, sizeof(UNICODE_STRING));
RtlZeroMemory(RemainingPart, sizeof(UNICODE_STRING));
/* Just quit if the string is empty */ /* Just quit if the string is empty */
if (!Name.Length) return; if (!Name.Length) return;
@ -169,14 +173,14 @@ FsRtlDissectName(IN UNICODE_STRING Name,
/* Set up the first result string */ /* Set up the first result string */
FirstPart->Buffer = Name.Buffer + SkipFirstSlash; FirstPart->Buffer = Name.Buffer + SkipFirstSlash;
FirstPart->Length = (FirstPosition - SkipFirstSlash) * sizeof(WCHAR); FirstPart->Length = (FirstPosition - SkipFirstSlash) * sizeof(WCHAR);
FirstPart->MaximumLength = Name.MaximumLength - FirstPart->Length; FirstPart->MaximumLength = FirstPart->Length;
/* And second one, if necessary */ /* And second one, if necessary */
if (FirstPosition < (Name.Length / sizeof(WCHAR))) if (FirstPosition < (Name.Length / sizeof(WCHAR)))
{ {
RemainingPart->Buffer = Name.Buffer + FirstPosition + 1; RemainingPart->Buffer = Name.Buffer + FirstPosition + 1;
RemainingPart->Length = (Name.Length - FirstPosition) * sizeof(WCHAR); RemainingPart->Length = Name.Length - (FirstPosition + 1) * sizeof(WCHAR);
RemainingPart->MaximumLength = Name.MaximumLength - RemainingPart->Length; RemainingPart->MaximumLength = RemainingPart->Length;
} }
} }