[ros-diffs] [pschweitzer] 35501: Implemented CdfsIsNameLegalDOS8Dot3 and use it to check filenames. It avoids calling Rtl* functions that need NLS. It uses FsRtl* functions instead. This fixes bug #2404. But, we also have to get rid of RtlGenerate8dot3Name to completely fix it.

pschweitzer at svn.reactos.org pschweitzer at svn.reactos.org
Thu Aug 21 10:54:00 CEST 2008


Author: pschweitzer
Date: Thu Aug 21 03:53:59 2008
New Revision: 35501

URL: http://svn.reactos.org/svn/reactos?rev=35501&view=rev
Log:
Implemented CdfsIsNameLegalDOS8Dot3 and use it to check filenames. It avoids calling Rtl* functions that need NLS. It uses FsRtl* functions instead.
This fixes bug #2404. But, we also have to get rid of RtlGenerate8dot3Name to completely fix it.

Modified:
    branches/pierre-fsd/drivers/filesystems/cdfs/cdfs.h
    branches/pierre-fsd/drivers/filesystems/cdfs/dirctl.c
    branches/pierre-fsd/drivers/filesystems/cdfs/fcb.c
    branches/pierre-fsd/drivers/filesystems/cdfs/misc.c

Modified: branches/pierre-fsd/drivers/filesystems/cdfs/cdfs.h
URL: http://svn.reactos.org/svn/reactos/branches/pierre-fsd/drivers/filesystems/cdfs/cdfs.h?rev=35501&r1=35500&r2=35501&view=diff
==============================================================================
--- branches/pierre-fsd/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] (original)
+++ branches/pierre-fsd/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] Thu Aug 21 03:53:59 2008
@@ -390,6 +390,9 @@
 CdfsFileFlagsToAttributes(PFCB Fcb,
 			  PULONG FileAttributes);
 
+BOOLEAN
+CdfsIsNameLegalDOS8Dot3(IN UNICODE_STRING FileName);
+
 
 /* rw.c */
 

Modified: branches/pierre-fsd/drivers/filesystems/cdfs/dirctl.c
URL: http://svn.reactos.org/svn/reactos/branches/pierre-fsd/drivers/filesystems/cdfs/dirctl.c?rev=35501&r1=35500&r2=35501&view=diff
==============================================================================
--- branches/pierre-fsd/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] (original)
+++ branches/pierre-fsd/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] Thu Aug 21 03:53:59 2008
@@ -176,7 +176,6 @@
   ULONG DirSize;
   PDIR_RECORD Record;
   LARGE_INTEGER StreamOffset;
-  BOOLEAN HasSpaces;
   GENERATE_NAME_CONTEXT NameContext;
 
   DPRINT("FindFile(Parent %x, FileToFind '%wZ', DirIndex: %d)\n",
@@ -289,8 +288,7 @@
       ShortName.MaximumLength = 26;
       ShortName.Buffer = ShortNameBuffer;
 
-      if ((RtlIsNameLegalDOS8Dot3(&LongName, NULL, &HasSpaces) == FALSE) ||
-	  (HasSpaces == TRUE))
+      if (!CdfsIsNameLegalDOS8Dot3(LongName))
 	{
 	  /* Build short name */
 	  RtlGenerate8dot3Name(&LongName,

Modified: branches/pierre-fsd/drivers/filesystems/cdfs/fcb.c
URL: http://svn.reactos.org/svn/reactos/branches/pierre-fsd/drivers/filesystems/cdfs/fcb.c?rev=35501&r1=35500&r2=35501&view=diff
==============================================================================
--- branches/pierre-fsd/drivers/filesystems/cdfs/fcb.c [iso-8859-1] (original)
+++ branches/pierre-fsd/drivers/filesystems/cdfs/fcb.c [iso-8859-1] Thu Aug 21 03:53:59 2008
@@ -462,7 +462,6 @@
   WCHAR ShortNameBuffer[13];
   UNICODE_STRING ShortName;
   UNICODE_STRING LongName;
-  BOOLEAN HasSpaces;
   GENERATE_NAME_CONTEXT NameContext;
 
 
@@ -522,8 +521,7 @@
       ShortName.Buffer = ShortNameBuffer;
       memset(ShortNameBuffer, 0, 26);
 
-      if ((RtlIsNameLegalDOS8Dot3(&LongName, NULL, &HasSpaces) == FALSE) ||
-          (HasSpaces == TRUE))
+      if (!CdfsIsNameLegalDOS8Dot3(LongName))
         {
           /* Build short name */
           RtlGenerate8dot3Name(&LongName,

Modified: branches/pierre-fsd/drivers/filesystems/cdfs/misc.c
URL: http://svn.reactos.org/svn/reactos/branches/pierre-fsd/drivers/filesystems/cdfs/misc.c?rev=35501&r1=35500&r2=35501&view=diff
==============================================================================
--- branches/pierre-fsd/drivers/filesystems/cdfs/misc.c [iso-8859-1] (original)
+++ branches/pierre-fsd/drivers/filesystems/cdfs/misc.c [iso-8859-1] Thu Aug 21 03:53:59 2008
@@ -95,4 +95,38 @@
 		    ((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
 }
 
+BOOLEAN
+CdfsIsNameLegalDOS8Dot3(IN UNICODE_STRING FileName
+    )
+{
+    ULONG i;
+    STRING DbcsName;
+    CHAR DbcsNameBuffer[12];
+
+    for (i = 0; i < FileName.Length / sizeof(WCHAR) ; i++)
+    {
+        /* Don't allow spaces in FileName */
+        if (FileName.Buffer[i] == L' ')
+            return FALSE;
+    }
+    
+    /* If FileName is finishing with a dot, remove it */
+    if (FileName.Buffer[FileName.Length / sizeof(WCHAR) - 1] == '.')
+    {
+        FileName.Length -= sizeof(WCHAR);
+    }
+
+    /* Finally, convert the string to call the FsRtl function */
+    DbcsName.MaximumLength = 12;
+    DbcsName.Buffer = DbcsNameBuffer;
+    if (!NT_SUCCESS(RtlUnicodeStringToCountedOemString(&DbcsName,
+                                                       &FileName,
+                                                       FALSE )))
+    {
+
+        return FALSE;
+    }
+    return FsRtlIsFatDbcsLegal(DbcsName, FALSE, FALSE, FALSE);
+}
+
 /* EOF */



More information about the Ros-diffs mailing list