diff --git a/drivers/filesystems/fastfat/create.c b/drivers/filesystems/fastfat/create.c index aadc990e37..0de08a9dd7 100644 --- a/drivers/filesystems/fastfat/create.c +++ b/drivers/filesystems/fastfat/create.c @@ -360,9 +360,7 @@ VfatOpenFile( return STATUS_CANNOT_DELETE; } - if ((vfatFCBIsRoot(Fcb) || - (Fcb->LongNameU.Length == sizeof(WCHAR) && Fcb->LongNameU.Buffer[0] == L'.') || - (Fcb->LongNameU.Length == 2 * sizeof(WCHAR) && Fcb->LongNameU.Buffer[0] == L'.' && Fcb->LongNameU.Buffer[1] == L'.')) && + if ((vfatFCBIsRoot(Fcb) || IsDotOrDotDot(&Fcb->LongNameU)) && BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE)) { // we cannot delete a '.', '..' or the root directory @@ -791,6 +789,13 @@ VfatCreateFile( Attributes |= FILE_ATTRIBUTE_ARCHIVE; } vfatSplitPathName(&PathNameU, NULL, &FileNameU); + + if (IsDotOrDotDot(&FileNameU)) + { + vfatReleaseFCB(DeviceExt, ParentFcb); + vfatAddToStat(DeviceExt, Fat.FailedCreates, 1); + return STATUS_OBJECT_NAME_INVALID; + } Status = VfatAddEntry(DeviceExt, &FileNameU, &pFcb, ParentFcb, RequestedOptions, Attributes, NULL); vfatReleaseFCB(DeviceExt, ParentFcb); diff --git a/drivers/filesystems/fastfat/finfo.c b/drivers/filesystems/fastfat/finfo.c index 755ba6a991..49738122b1 100644 --- a/drivers/filesystems/fastfat/finfo.c +++ b/drivers/filesystems/fastfat/finfo.c @@ -380,9 +380,7 @@ VfatSetDispositionInformation( return STATUS_CANNOT_DELETE; } - if (vfatFCBIsRoot(FCB) || - (FCB->LongNameU.Length == sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.') || - (FCB->LongNameU.Length == 2 * sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.' && FCB->LongNameU.Buffer[1] == L'.')) + if (vfatFCBIsRoot(FCB) || IsDotOrDotDot(&FCB->LongNameU)) { /* we cannot delete a '.', '..' or the root directory */ return STATUS_ACCESS_DENIED; @@ -804,6 +802,12 @@ VfatSetRenameInformation( vfatSplitPathName(&NewName, &NewPath, &NewFile); DPRINT("New dir: %wZ, New file: %wZ\n", &NewPath, &NewFile); + if (IsDotOrDotDot(&NewFile)) + { + Status = STATUS_OBJECT_NAME_INVALID; + goto Cleanup; + } + if (vfatFCBIsDirectory(FCB) && !IsListEmpty(&FCB->ParentListHead)) { if (IsThereAChildOpened(FCB)) diff --git a/drivers/filesystems/fastfat/string.c b/drivers/filesystems/fastfat/string.c index 6a8f65a48f..e245e5efe6 100644 --- a/drivers/filesystems/fastfat/string.c +++ b/drivers/filesystems/fastfat/string.c @@ -3,7 +3,8 @@ * PROJECT: ReactOS kernel * FILE: drivers/fs/vfat/string.c * PURPOSE: VFAT Filesystem - * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com) + * PROGRAMMERS: Jason Filby (jasonfilby@yahoo.com) + * Doug Lyons (douglyons at douglyons dot com) * */ @@ -24,3 +25,10 @@ vfatIsLongIllegal( { return wcschr(long_illegals, c) ? TRUE : FALSE; } + +BOOLEAN +IsDotOrDotDot(PCUNICODE_STRING File) +{ + return ((File->Length == sizeof(WCHAR) && File->Buffer[0] == L'.') || + (File->Length == 2 * sizeof(WCHAR) && File->Buffer[0] == L'.' && File->Buffer[1] == L'.')); +} diff --git a/drivers/filesystems/fastfat/vfat.h b/drivers/filesystems/fastfat/vfat.h index 478753447d..403695844f 100644 --- a/drivers/filesystems/fastfat/vfat.h +++ b/drivers/filesystems/fastfat/vfat.h @@ -1221,6 +1221,10 @@ BOOLEAN vfatIsLongIllegal( WCHAR c); +BOOLEAN +IsDotOrDotDot( + PCUNICODE_STRING File); + /* volume.c */ NTSTATUS