From e67bbc79a96c418d6726eb9ebf7f714b4b37cd6c Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Thu, 16 Oct 2014 16:57:11 +0000 Subject: [PATCH] [NPFS] - Don't truncate pipe name in the RootPipe case in NpCreateFcb. Found by Windows's RtlInsertUnicodePrefix implementation -- which might indicate that ours is broken. svn path=/trunk/; revision=64763 --- reactos/drivers/filesystems/npfs/strucsup.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/filesystems/npfs/strucsup.c b/reactos/drivers/filesystems/npfs/strucsup.c index 73d0360f79d..29a8c851969 100644 --- a/reactos/drivers/filesystems/npfs/strucsup.c +++ b/reactos/drivers/filesystems/npfs/strucsup.c @@ -218,7 +218,6 @@ NpCreateFcb(IN PNP_DCB Dcb, PNP_FCB Fcb; BOOLEAN RootPipe; PWCHAR NameBuffer; - ULONG BufferOffset; USHORT Length, MaximumLength; PAGED_CODE(); @@ -233,6 +232,7 @@ NpCreateFcb(IN PNP_DCB Dcb, RootPipe = FALSE; if (PipeName->Buffer[0] != OBJ_NAME_PATH_SEPARATOR) { + Length += sizeof(OBJ_NAME_PATH_SEPARATOR); MaximumLength += sizeof(OBJ_NAME_PATH_SEPARATOR); RootPipe = TRUE; if (MaximumLength < sizeof(WCHAR)) @@ -262,15 +262,21 @@ NpCreateFcb(IN PNP_DCB Dcb, InsertTailList(&Dcb->FcbList, &Fcb->DcbEntry); - BufferOffset = 0; if (RootPipe) { NameBuffer[0] = OBJ_NAME_PATH_SEPARATOR; - BufferOffset = 1; + RtlCopyMemory(NameBuffer + 1, + PipeName->Buffer, + PipeName->Length); + } + else + { + RtlCopyMemory(NameBuffer, + PipeName->Buffer, + PipeName->Length); } - RtlCopyMemory(NameBuffer + BufferOffset, PipeName->Buffer, Length); - NameBuffer[BufferOffset + (Length / sizeof(WCHAR))] = UNICODE_NULL; + NameBuffer[Length / sizeof(WCHAR)] = UNICODE_NULL; Fcb->FullName.Length = Length; Fcb->FullName.MaximumLength = MaximumLength;