Reject more broken file names on open/create.
Fixes a few kmtests:IoFilesystem tests
svn path=/trunk/; revision=73923
BOOLEAN PagingFileCreate;
BOOLEAN Dots;
BOOLEAN OpenTargetDir;
BOOLEAN PagingFileCreate;
BOOLEAN Dots;
BOOLEAN OpenTargetDir;
+ BOOLEAN TrailingBackslash;
UNICODE_STRING FileNameU;
UNICODE_STRING PathNameU;
ULONG Attributes;
UNICODE_STRING FileNameU;
UNICODE_STRING PathNameU;
ULONG Attributes;
PathNameU = FileObject->FileName;
c = PathNameU.Buffer + PathNameU.Length / sizeof(WCHAR);
last = c - 1;
PathNameU = FileObject->FileName;
c = PathNameU.Buffer + PathNameU.Length / sizeof(WCHAR);
last = c - 1;
+
+ TrailingBackslash = (*last == L'\\');
+
Dots = TRUE;
while (c-- > PathNameU.Buffer)
{
Dots = TRUE;
while (c-- > PathNameU.Buffer)
{
{
return STATUS_OBJECT_NAME_INVALID;
}
{
return STATUS_OBJECT_NAME_INVALID;
}
+ if (*c == L'\\' && (c - 1) > PathNameU.Buffer &&
+ *(c - 1) == L'\\')
+ {
+ return STATUS_OBJECT_NAME_INVALID;
+ }
+
last = c - 1;
Dots = TRUE;
}
last = c - 1;
Dots = TRUE;
}
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
+ if (TrailingBackslash & !BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
+ {
+ return STATUS_OBJECT_NAME_INVALID;
+ }
+
Attributes = Stack->Parameters.Create.FileAttributes & ~FILE_ATTRIBUTE_NORMAL;
if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
Attributes |= FILE_ATTRIBUTE_ARCHIVE;
Attributes = Stack->Parameters.Create.FileAttributes & ~FILE_ATTRIBUTE_NORMAL;
if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
Attributes |= FILE_ATTRIBUTE_ARCHIVE;
VfatCloseFile (DeviceExt, FileObject);
return STATUS_NOT_A_DIRECTORY;
}
VfatCloseFile (DeviceExt, FileObject);
return STATUS_NOT_A_DIRECTORY;
}
+ if (!vfatFCBIsDirectory(pFcb) && TrailingBackslash)
+ {
+ VfatCloseFile (DeviceExt, FileObject);
+ return STATUS_OBJECT_NAME_INVALID;
+ }
#ifndef USE_ROS_CC_AND_FS
if (!vfatFCBIsDirectory(pFcb))
{
#ifndef USE_ROS_CC_AND_FS
if (!vfatFCBIsDirectory(pFcb))
{