Index: fdi.c =================================================================== --- dll/win32/cabinet/fdi.c (revision 73222) +++ dll/win32/cabinet/fdi.c (working copy) @@ -2039,11 +2039,13 @@ fullpath[0] = '\0'; if (pathlen) { strcpy(fullpath, userpath); - if (fullpath[pathlen - 1] != '\\') - strcat(fullpath, "\\"); + if (fullpath[pathlen - 1] == '\\') + fullpath[pathlen - 1] = '\0'; } - if (filenamelen) + if (filenamelen) { + strcat(fullpath, "\\"); strcat(fullpath, cab->mii.nextname); + } TRACE("full cab path/file name: %s\n", debugstr_a(fullpath)); Index: create.c =================================================================== --- drivers/filesystems/fastfat/create.c (revision 73222) +++ drivers/filesystems/fastfat/create.c (working copy) @@ -508,6 +508,7 @@ UNICODE_STRING FileNameU; UNICODE_STRING PathNameU; ULONG Attributes; + BOOLEAN TrailingBackslash; /* Unpack the various parameters. */ Stack = IoGetCurrentIrpStackLocation(Irp); @@ -650,9 +651,11 @@ return STATUS_OBJECT_NAME_INVALID; } + TrailingBackslash = FALSE; if (PathNameU.Length > sizeof(WCHAR) && PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\') { PathNameU.Length -= sizeof(WCHAR); + TrailingBackslash = TRUE; } if (PathNameU.Length > sizeof(WCHAR) && PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\') @@ -799,7 +802,14 @@ { Attributes = Stack->Parameters.Create.FileAttributes & ~FILE_ATTRIBUTE_NORMAL; if (!(RequestedOptions & FILE_DIRECTORY_FILE)) + { + if (TrailingBackslash) + { + vfatReleaseFCB(DeviceExt, ParentFcb); + return STATUS_OBJECT_NAME_INVALID; + } Attributes |= FILE_ATTRIBUTE_ARCHIVE; + } vfatSplitPathName(&PathNameU, NULL, &FileNameU); Status = VfatAddEntry(DeviceExt, &FileNameU, &pFcb, ParentFcb, RequestedOptions, (UCHAR)(Attributes & FILE_ATTRIBUTE_VALID_FLAGS), NULL); @@ -848,16 +858,21 @@ vfatReleaseFCB(DeviceExt, ParentFcb); } + pFcb = FileObject->FsContext; + /* Otherwise fail if the caller wanted to create a new file */ if (RequestedDisposition == FILE_CREATE) { + VfatCloseFile(DeviceExt, FileObject); + if (TrailingBackslash && + !(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)) + { + return STATUS_OBJECT_NAME_INVALID; + } Irp->IoStatus.Information = FILE_EXISTS; - VfatCloseFile(DeviceExt, FileObject); return STATUS_OBJECT_NAME_COLLISION; } - pFcb = FileObject->FsContext; - if (pFcb->OpenHandleCount != 0) { Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess, @@ -887,6 +902,12 @@ VfatCloseFile (DeviceExt, FileObject); return STATUS_NOT_A_DIRECTORY; } + if (TrailingBackslash && + !(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)) + { + VfatCloseFile (DeviceExt, FileObject); + return STATUS_OBJECT_NAME_INVALID; + } #ifndef USE_ROS_CC_AND_FS if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)) {