git-svn: trunk@4848
Török Edvin authored on 2009/02/23 21:35:45... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Mon Feb 23 14:53:39 EET 2009 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * libclamav/regex_list.c, libclamav/regex_list.h, |
|
4 |
+ unit_tests/check_regex.c, unit_tests/input/daily.wdb: fix match with |
|
5 |
+ root regex (bb #1421). |
|
6 |
+ |
|
1 | 7 |
Mon Feb 23 14:10:01 EET 2009 (edwin) |
2 | 8 |
------------------------------------ |
3 | 9 |
* 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 |
272 | 272 |
{ |
273 | 273 |
char *buffer = cli_malloc(buffer_len+1); |
274 | 274 |
char *bufrev; |
275 |
- int rc = 0; |
|
275 |
+ int rc = 0, root; |
|
276 | 276 |
struct cli_ac_data mdata; |
277 | 277 |
struct cli_ac_result *res = NULL; |
278 | 278 |
|
... | ... |
@@ -309,9 +309,15 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di |
309 | 309 |
cli_ac_freedata(&mdata); |
310 | 310 |
|
311 | 311 |
rc = 0; |
312 |
- while(res) { |
|
312 |
+ root = matcher->root_regex_idx; |
|
313 |
+ while(res || root) { |
|
313 | 314 |
struct cli_ac_result *q; |
314 |
- regex = res->customdata; |
|
315 |
+ if (!res) { |
|
316 |
+ regex = matcher->suffix_regexes[root].head; |
|
317 |
+ root = 0; |
|
318 |
+ } else { |
|
319 |
+ regex = res->customdata; |
|
320 |
+ } |
|
315 | 321 |
while(!rc && regex) { |
316 | 322 |
/* loop over multiple regexes corresponding to |
317 | 323 |
* this suffix */ |
... | ... |
@@ -324,9 +330,11 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di |
324 | 324 |
if(rc) *info = regex->pattern; |
325 | 325 |
regex = regex->nxt; |
326 | 326 |
} |
327 |
- q = res; |
|
328 |
- res = res->next; |
|
329 |
- free(q); |
|
327 |
+ if (res) { |
|
328 |
+ q = res; |
|
329 |
+ res = res->next; |
|
330 |
+ free(q); |
|
331 |
+ } |
|
330 | 332 |
} |
331 | 333 |
free(buffer); |
332 | 334 |
if(!rc) |
... | ... |
@@ -693,6 +701,8 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le |
693 | 693 |
return CL_EMEM; |
694 | 694 |
matcher->suffix_regexes[n].tail = regex; |
695 | 695 |
matcher->suffix_regexes[n].head = regex; |
696 |
+ if (suffix[0] == '/' && suffix[1] == '\0') |
|
697 |
+ matcher->root_regex_idx = n; |
|
696 | 698 |
add_newsuffix(matcher, regex, suffix, suffix_len); |
697 | 699 |
cli_dbgmsg(MODULE "added new suffix %s, for regex: %s\n", suffix, regex->pattern); |
698 | 700 |
} |
... | ... |
@@ -198,6 +198,8 @@ static const struct rtest { |
198 | 198 |
{NULL, |
199 | 199 |
"http://key.com","go to key.com",2 |
200 | 200 |
}, |
201 |
+ {":.+\\.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))?)([/?].*)?/", |
|
202 |
+ "http://www.paypal.com", "pics.ebay.com", 1}, |
|
201 | 203 |
{NULL, "http://somefakeurl.example.com","someotherdomain-key.com",2}, |
202 | 204 |
{NULL, "http://somefakeurl.example.com","someotherdomain.key.com",0}, |
203 | 205 |
{NULL, "http://1.test.example.com/something","test",3}, |
... | ... |
@@ -28,4 +28,4 @@ X:.+:.+rcm\.amazon\.com([/?].*)?:17- |
28 | 28 |
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- |
29 | 29 |
M:www.paypal.com%a0:www.paypal.com |
30 | 30 |
M:www.monster.fr:media.monster.com |
31 |
-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- |
|
31 |
+X:.+\.paypal\.com:.+\.ebay\.com |