mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2026-05-06 22:55:49 -04:00
match_regex: make sure --exclude/include patterns with trailing slashes are handled correctly (bb#820)
git-svn: trunk@3607
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
Mon Feb 11 12:21:19 CET 2008 (tk)
|
||||
---------------------------------
|
||||
* clamscan: match_regex: make sure --exclude/include patterns with
|
||||
trailing slashes are handled correctly (bb#820)
|
||||
|
||||
Mon Feb 11 11:15:57 CET 2008 (tk)
|
||||
---------------------------------
|
||||
* shared/misc.c: fix return value of daemonize() under Windows&OS/2 (thx NJH)
|
||||
|
||||
@@ -130,7 +130,10 @@ int match_regex(const char *filename, const char *pattern)
|
||||
{
|
||||
regex_t reg;
|
||||
int match, flags;
|
||||
#if !defined(C_CYGWIN) && !defined(C_OS2)
|
||||
char fname[513];
|
||||
size_t len;
|
||||
|
||||
#if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_WINDOWS)
|
||||
flags = REG_EXTENDED;
|
||||
#else
|
||||
flags = REG_EXTENDED | REG_ICASE; /* case insensitive on Windows */
|
||||
@@ -139,7 +142,24 @@ int match_regex(const char *filename, const char *pattern)
|
||||
logg("!%s: Could not parse regular expression %s.\n", filename, pattern);
|
||||
return 2;
|
||||
}
|
||||
match = (cli_regexec(®, filename, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
|
||||
|
||||
#if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_WINDOWS)
|
||||
if(pattern[strlen(pattern) - 1] == '/') {
|
||||
snprintf(fname, 511, "%s/", filename);
|
||||
fname[512] = 0;
|
||||
#else
|
||||
if(pattern[strlen(pattern) - 1] == '\\') {
|
||||
strncpy(fname, filename, 510);
|
||||
len = strlen(fname);
|
||||
if(fname[len - 1] != '\\') {
|
||||
fname[len] = '\\';
|
||||
fname[len + 1] = 0;
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
strncpy(fname, filename, 513);
|
||||
|
||||
match = (cli_regexec(®, fname, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
|
||||
cli_regfree(®);
|
||||
return match;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user