Fixed a typo in RtlGenerate8dot3Name().
authorEric Kohl <eric.kohl@reactos.org>
Thu, 6 Jun 2002 16:17:26 +0000 (16:17 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 6 Jun 2002 16:17:26 +0000 (16:17 +0000)
Added more tests to RtlIsNameLegalDOS8Dot3().

svn path=/trunk/; revision=3012

reactos/lib/ntdll/rtl/dos8dot3.c
reactos/ntoskrnl/rtl/dos8dot3.c

index ce9b722..8a7a590 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dos8dot3.c,v 1.1 2002/06/05 16:50:43 ekohl Exp $
+/* $Id: dos8dot3.c,v 1.2 2002/06/06 16:17:09 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -129,7 +129,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
 
   if ((Context->NameLength == CopyLength) &&
       (wcsncmp(Context->NameBuffer, NameBuffer, CopyLength) == 0) &&
-      (Context->ExtensionLength = ExtLength) &&
+      (Context->ExtensionLength == ExtLength) &&
       (wcsncmp(Context->ExtensionBuffer, ExtBuffer, ExtLength) == 0))
     CurrentIndex = Context->LastIndexValue + 1;
   else
@@ -225,10 +225,11 @@ RtlIsNameLegalDOS8Dot3(IN PUNICODE_STRING UnicodeName,
                break;
 
              case '.':
-               if ((HasDot) ||         /* two dots */
-                   (!i) ||             /* point is first char */
-                   (i + 1 == Length) ||/* point is last char */
-                   (Length - i > 4))   /* more than 3 chars of extension */
+               if ((HasDot) ||                 /* two or more dots */
+                   (i == 0) ||                 /* dot is first char */
+                   (i + 1 == Length) ||        /* dot is last char */
+                   (Length - i > 4) ||         /* more than 3 chars of extension */
+                   (HasDot == FALSE && i > 8)) /* name is longer than 8 chars */
                  return(FALSE);
                HasDot = TRUE;
                break;
@@ -236,6 +237,12 @@ RtlIsNameLegalDOS8Dot3(IN PUNICODE_STRING UnicodeName,
        }
     }
 
+  /* Name is longer than 8 chars and does not have an extension */
+  if (Length > 8 && HasDot == FALSE)
+    {
+      return(FALSE);
+    }
+
   if (SpacesFound)
     *SpacesFound = HasSpace;
 
index 81a855a..dcba921 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dos8dot3.c,v 1.1 2002/06/05 16:52:43 ekohl Exp $
+/* $Id: dos8dot3.c,v 1.2 2002/06/06 16:17:26 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -124,7 +124,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
   CopyLength = min(NameLength, (CurrentIndex < 10) ? 6 : 5);
   if ((Context->NameLength == CopyLength) &&
       (wcsncmp(Context->NameBuffer, NameBuffer, CopyLength) == 0) &&
-      (Context->ExtensionLength = ExtLength) &&
+      (Context->ExtensionLength == ExtLength) &&
       (wcsncmp(Context->ExtensionBuffer, ExtBuffer, ExtLength) == 0))
     CurrentIndex = Context->LastIndexValue + 1;
   else
@@ -219,10 +219,11 @@ RtlIsNameLegalDOS8Dot3(IN PUNICODE_STRING UnicodeName,
                break;
 
              case '.':
-               if ((HasDot) ||         /* two dots */
-                   (!i) ||             /* point is first char */
-                   (i + 1 == Length) ||/* point is last char */
-                   (Length - i > 4))   /* more than 3 chars of extension */
+               if ((HasDot) ||                 /* two or more dots */
+                   (i == 0) ||                 /* dot is first char */
+                   (i + 1 == Length) ||        /* dot is last char */
+                   (Length - i > 4) ||         /* more than 3 chars of extension */
+                   (HasDot == FALSE && i > 8)) /* name is longer than 8 chars */
                  return(FALSE);
                HasDot = TRUE;
                break;
@@ -230,6 +231,12 @@ RtlIsNameLegalDOS8Dot3(IN PUNICODE_STRING UnicodeName,
        }
     }
 
+  /* Name is longer than 8 chars and does not have an extension */
+  if (Length > 8 && HasDot == FALSE)
+    {
+      return(FALSE);
+    }
+
   if (SpacesFound)
     *SpacesFound = HasSpace;