]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE140-windows-pattern-matching-20051014
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 14 Oct 2005 12:24:26 +0000 (12:24 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 14 Oct 2005 12:24:26 +0000 (12:24 +0000)
FIXES 4623

Pattern matching was broken.   '?' should match zero characters if it
appears before a '.' or at the end of the file name.

(cherry picked from commit 41fe908bead6b30e41fd9e4f5084cd5e1dc3ca4a)

src/WINNT/afsd/smb3.c

index 389449b22c8f26b957bc0599363e5609e863e058..fd37856ea077eece49d5428962a485516260c7aa 100644 (file)
@@ -3558,9 +3558,10 @@ szWildCardMatchFileName(PSZ pattern, PSZ name, int casefold)
     while (*name) {
         switch (*pattern) {
         case '?':
-            if (*name == '.') 
-                return FALSE;
-            ++pattern, ++name;
+           ++pattern;
+            if (*name == '.')
+               continue;
+            ++name;
             break;
          case '*':
             ++pattern;
@@ -3582,10 +3583,12 @@ szWildCardMatchFileName(PSZ pattern, PSZ name, int casefold)
         } /* endswitch */
     } /* endwhile */ 
 
-    if (*pattern == '\0' || *pattern == '*' && *(pattern+1) == '\0')
-        return TRUE;
-    else 
-        return FALSE;
+    /* if all we have left are wildcards, then we match */
+    for (;*pattern; pattern++) {
+       if (*pattern != '*' && *pattern != '?')
+           return FALSE;
+    }
+    return TRUE;
 }
 
 /* do a case-folding search of the star name mask with the name in namep.