From 8ba55e9b6f271d5bb871695af33ce3d4e58b0242 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 11 May 2013 09:52:37 +0000 Subject: [PATCH] [CDFS] * Fix the mismatch between sizeof and countof quantities in CdfsMakeFCBFromDirEntry. * Properly account for '\\' and '\0'. * Fix one more debug print specifier. svn path=/trunk/; revision=58988 --- reactos/drivers/filesystems/cdfs/fcb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/filesystems/cdfs/fcb.c b/reactos/drivers/filesystems/cdfs/fcb.c index b79de4df491..61635558474 100644 --- a/reactos/drivers/filesystems/cdfs/fcb.c +++ b/reactos/drivers/filesystems/cdfs/fcb.c @@ -363,8 +363,9 @@ CdfsMakeFCBFromDirEntry(PVCB Vcb, PFCB rcFCB; ULONG Size; - if (LongName [0] != 0 && wcslen (DirectoryFCB->PathName) + - sizeof(WCHAR) + wcslen (LongName) > MAX_PATH) + /* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */ + if ((LongName[0] != 0) && + (wcslen(DirectoryFCB->PathName) + 1 + wcslen(LongName) + 1 > MAX_PATH)) { return(STATUS_OBJECT_NAME_INVALID); } @@ -411,7 +412,7 @@ CdfsMakeFCBFromDirEntry(PVCB Vcb, CdfsAddFCBToTable(Vcb, rcFCB); *fileFCB = rcFCB; - DPRINT("%S %d %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart); + DPRINT("%S %u %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart); return(STATUS_SUCCESS); }