mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 23:40:13 +00:00
STABLE14-cifs-pattern-match-20040921
FIXES 15365
The pattern matching algorithm was failing to match strings when the
pattern terminated in a '*'. The logic was also too complex because
it failed to simply the patterns prior to processing. Any combination
of '*' and '?' == '*' according to the Windows file name pattern
matching rules.
(cherry picked from commit a135e0d30c
)
This commit is contained in:
parent
02368492c4
commit
8996b91f97
@ -1,4 +1,7 @@
|
|||||||
Since 1.3.71:
|
Since 1.3.71:
|
||||||
|
* Fix the pattern matching algorithm to properly match patterns
|
||||||
|
ending with a '*'.
|
||||||
|
|
||||||
* smb_ReceiveCoreRename() was factored to produce smb_Rename()
|
* smb_ReceiveCoreRename() was factored to produce smb_Rename()
|
||||||
which is used by both the original function and the new
|
which is used by both the original function and the new
|
||||||
smb_ReceiveNTRename(). smb_ReceiveNTRename() supports the
|
smb_ReceiveNTRename(). smb_ReceiveNTRename() supports the
|
||||||
|
@ -196,10 +196,7 @@ List of unfunded projects:
|
|||||||
afsmap.exe <drive> /DELETE
|
afsmap.exe <drive> /DELETE
|
||||||
22. Write-through caching appears to be unsupported. Files copied to AFS
|
22. Write-through caching appears to be unsupported. Files copied to AFS
|
||||||
do not end up in the local cache.
|
do not end up in the local cache.
|
||||||
23. The Win32 API CreateHardLink() is not properly supported by the SMB/CIFS
|
23. Missing SMB/CIFS functions:
|
||||||
server. It neither returns a valid error nor does it perform the
|
|
||||||
operation.
|
|
||||||
24. Missing SMB/CIFS functions:
|
|
||||||
Find
|
Find
|
||||||
FindUnique
|
FindUnique
|
||||||
FindClose
|
FindClose
|
||||||
@ -207,7 +204,8 @@ List of unfunded projects:
|
|||||||
WriteBulk
|
WriteBulk
|
||||||
WriteBulkData
|
WriteBulkData
|
||||||
Tran2::SessionSetup
|
Tran2::SessionSetup
|
||||||
|
24. StoreBehind mode is not implemented. Or more correctly, all data is
|
||||||
|
written directly to the server and is not cached. Writes invalidate
|
||||||
|
the local cache entries which are then read back from the server.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3242,40 +3242,41 @@ VOID initUpperCaseTable(VOID)
|
|||||||
// Return value
|
// Return value
|
||||||
// BOOL : TRUE/FALSE (match/mistmatch)
|
// BOOL : TRUE/FALSE (match/mistmatch)
|
||||||
|
|
||||||
BOOL szWildCardMatchFileName(PSZ pattern, PSZ name) {
|
BOOL
|
||||||
PSZ pename; // points to the last 'name' character
|
szWildCardMatchFileName(PSZ pattern, PSZ name)
|
||||||
PSZ p;
|
{
|
||||||
pename = name + strlen(name) - 1;
|
PSZ pename; // points to the last 'name' character
|
||||||
while (*name) {
|
PSZ p;
|
||||||
switch (*pattern) {
|
pename = name + strlen(name) - 1;
|
||||||
case '?':
|
while (*name) {
|
||||||
case '>':
|
switch (*pattern) {
|
||||||
if (*(++pattern) != '<' || *(++pattern) != '*') {
|
case '?':
|
||||||
if (*name == '.')
|
if (*name == '.')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
++name;
|
++pattern, ++name;
|
||||||
break;
|
break;
|
||||||
} /* endif */
|
|
||||||
case '<':
|
|
||||||
case '*':
|
case '*':
|
||||||
while ((*pattern == '<') || (*pattern == '*') || (*pattern == '?') || (*pattern == '>'))
|
++pattern;
|
||||||
++pattern;
|
if (*pattern == '\0')
|
||||||
if (!*pattern)
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
for (p = pename; p >= name; --p) {
|
for (p = pename; p >= name; --p) {
|
||||||
if ((mapCaseTable[*p] == mapCaseTable[*pattern]) &&
|
if ((mapCaseTable[*p] == mapCaseTable[*pattern]) &&
|
||||||
szWildCardMatchFileName(pattern + 1, p + 1))
|
szWildCardMatchFileName(pattern + 1, p + 1))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} /* endfor */
|
} /* endfor */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
default:
|
default:
|
||||||
if (mapCaseTable[*name] != mapCaseTable[*pattern])
|
if (mapCaseTable[*name] != mapCaseTable[*pattern])
|
||||||
return FALSE;
|
return FALSE;
|
||||||
++pattern, ++name;
|
++pattern, ++name;
|
||||||
break;
|
break;
|
||||||
} /* endswitch */
|
} /* endswitch */
|
||||||
} /* endwhile */
|
} /* endwhile */
|
||||||
return !*pattern;
|
|
||||||
|
if (*pattern == '\0' || *pattern == '*' && *(pattern+1) == '\0')
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do a case-folding search of the star name mask with the name in namep.
|
/* do a case-folding search of the star name mask with the name in namep.
|
||||||
@ -3283,11 +3284,53 @@ BOOL szWildCardMatchFileName(PSZ pattern, PSZ name) {
|
|||||||
*/
|
*/
|
||||||
int smb_V3MatchMask(char *namep, char *maskp, int flags)
|
int smb_V3MatchMask(char *namep, char *maskp, int flags)
|
||||||
{
|
{
|
||||||
/* make sure we only match 8.3 names, if requested */
|
char * newmask;
|
||||||
if ((flags & CM_FLAG_8DOT3) && !cm_Is8Dot3(namep))
|
int i, j, star, qmark, retval;
|
||||||
|
|
||||||
|
/* make sure we only match 8.3 names, if requested */
|
||||||
|
if ((flags & CM_FLAG_8DOT3) && !cm_Is8Dot3(namep))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return szWildCardMatchFileName(maskp, namep) ? 1:0;
|
/* optimize the pattern:
|
||||||
|
* if there is a mixture of '?' and '*',
|
||||||
|
* for example the sequence "*?*?*?*"
|
||||||
|
* must be turned into the form "*"
|
||||||
|
*/
|
||||||
|
newmask = (char *)malloc(strlen(maskp)+1);
|
||||||
|
for ( i=0, j=0, star=0, qmark=0; maskp[i]; i++) {
|
||||||
|
switch ( maskp[i] ) {
|
||||||
|
case '?':
|
||||||
|
case '>':
|
||||||
|
qmark++;
|
||||||
|
break;
|
||||||
|
case '<':
|
||||||
|
case '*':
|
||||||
|
star++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ( star ) {
|
||||||
|
newmask[j++] = '*';
|
||||||
|
} else if ( qmark ) {
|
||||||
|
while ( qmark-- )
|
||||||
|
newmask[j++] = '?';
|
||||||
|
}
|
||||||
|
newmask[j++] = maskp[i];
|
||||||
|
star = 0;
|
||||||
|
qmark = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( star ) {
|
||||||
|
newmask[j++] = '*';
|
||||||
|
} else if ( qmark ) {
|
||||||
|
while ( qmark-- )
|
||||||
|
newmask[j++] = '?';
|
||||||
|
}
|
||||||
|
newmask[j++] = '\0';
|
||||||
|
|
||||||
|
retval = szWildCardMatchFileName(newmask, namep) ? 1:0;
|
||||||
|
|
||||||
|
free(newmask);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* USE_OLD_MATCHING */
|
#else /* USE_OLD_MATCHING */
|
||||||
|
Loading…
Reference in New Issue
Block a user