fix match with root regex (bb #1421).

git-svn: trunk@4848
remotes/push_mirror/0.95
Török Edvin 17 years ago
parent 3dc90d4a30
commit d4e1cb474f
  1. 6
      ChangeLog
  2. 22
      libclamav/regex_list.c
  3. 1
      libclamav/regex_list.h
  4. 2
      unit_tests/check_regex.c
  5. 2
      unit_tests/input/daily.wdb

@ -1,3 +1,9 @@
Mon Feb 23 14:53:39 EET 2009 (edwin)
------------------------------------
* libclamav/regex_list.c, libclamav/regex_list.h,
unit_tests/check_regex.c, unit_tests/input/daily.wdb: fix match with
root regex (bb #1421).
Mon Feb 23 14:10:01 EET 2009 (edwin)
------------------------------------
* clamd/session.c: stop scanning when client disconnects in

@ -272,7 +272,7 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di
{
char *buffer = cli_malloc(buffer_len+1);
char *bufrev;
int rc = 0;
int rc = 0, root;
struct cli_ac_data mdata;
struct cli_ac_result *res = NULL;
@ -309,9 +309,15 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di
cli_ac_freedata(&mdata);
rc = 0;
while(res) {
root = matcher->root_regex_idx;
while(res || root) {
struct cli_ac_result *q;
regex = res->customdata;
if (!res) {
regex = matcher->suffix_regexes[root].head;
root = 0;
} else {
regex = res->customdata;
}
while(!rc && regex) {
/* loop over multiple regexes corresponding to
* this suffix */
@ -324,9 +330,11 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di
if(rc) *info = regex->pattern;
regex = regex->nxt;
}
q = res;
res = res->next;
free(q);
if (res) {
q = res;
res = res->next;
free(q);
}
}
free(buffer);
if(!rc)
@ -693,6 +701,8 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le
return CL_EMEM;
matcher->suffix_regexes[n].tail = regex;
matcher->suffix_regexes[n].head = regex;
if (suffix[0] == '/' && suffix[1] == '\0')
matcher->root_regex_idx = n;
add_newsuffix(matcher, regex, suffix, suffix_len);
cli_dbgmsg(MODULE "added new suffix %s, for regex: %s\n", suffix, regex->pattern);
}

@ -47,6 +47,7 @@ struct regex_matcher {
struct hashtable suffix_hash;
size_t suffix_cnt;
struct regex_list_ht *suffix_regexes;
size_t root_regex_idx;
size_t regex_cnt;
regex_t **all_pregs;
struct cli_matcher suffixes;

@ -198,6 +198,8 @@ static const struct rtest {
{NULL,
"http://key.com","go to key.com",2
},
{":.+\\.paypal\\.(com|de|fr|it)([/?].*)?:.+\\.ebay\\.(at|be|ca|ch|co\\.uk|de|es|fr|ie|in|it|nl|ph|pl|com(\\.(au|cn|hk|my|sg))?)([/?].*)?/",
"http://www.paypal.com", "pics.ebay.com", 1},
{NULL, "http://somefakeurl.example.com","someotherdomain-key.com",2},
{NULL, "http://somefakeurl.example.com","someotherdomain.key.com",0},
{NULL, "http://1.test.example.com/something","test",3},

@ -28,4 +28,4 @@ X:.+:.+rcm\.amazon\.com([/?].*)?:17-
X:.+\.ebay\.com([/?].*)?:.+\.ebay\.(at|be|ca|ch|co\.uk|de|es|fr|ie|in|it|nl|ph|pl|com\.(au|cn|hk|my|sg))([/?].*)?:17-
M:www.paypal.com%a0:www.paypal.com
M:www.monster.fr:media.monster.com
X:.+\.paypal\.(com|de|fr|it)([/?].*)?:.+\.ebay\.(at|be|ca|ch|co\.uk|de|es|fr|ie|in|it|nl|ph|pl|com(\.(au|cn|hk|my|sg))?)([/?].*)?:17-
X:.+\.paypal\.com:.+\.ebay\.com

Loading…
Cancel
Save