git-svn: trunk@4207
Tomasz Kojm authored on 2008/09/25 20:05:21... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Thu Sep 25 13:16:15 CEST 2008 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/matcher-ac.c: improve detection and reordering of zero-only |
|
4 |
+ subpatterns (bb#1188) |
|
5 |
+ |
|
1 | 6 |
Wed Sep 24 15:17:12 CEST 2008 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/ole2_extract.c: handle files with unusual parameters (bb#954) |
... | ... |
@@ -1080,8 +1080,8 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1080 | 1080 |
{ |
1081 | 1081 |
struct cli_ac_patt *new; |
1082 | 1082 |
char *pt, *pt2, *hex = NULL, *hexcpy = NULL; |
1083 |
- uint16_t i, j, ppos = 0, pend, *dec; |
|
1084 |
- uint8_t wprefix = 0, zprefix = 1, plen = 0; |
|
1083 |
+ uint16_t i, j, ppos = 0, pend, *dec, nzpos = 0; |
|
1084 |
+ uint8_t wprefix = 0, zprefix = 1, plen = 0, nzplen = 0; |
|
1085 | 1085 |
struct cli_ac_alt *newalt, *altpt, **newtable; |
1086 | 1086 |
int ret, error = CL_SUCCESS; |
1087 | 1087 |
|
... | ... |
@@ -1356,12 +1356,22 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1356 | 1356 |
ppos = i; |
1357 | 1357 |
} |
1358 | 1358 |
} |
1359 |
- if(plen >= root->ac_maxdepth && (new->pattern[ppos] || new->pattern[ppos + 1])) |
|
1360 |
- break; |
|
1359 |
+ if(new->pattern[ppos] || new->pattern[ppos + 1]) { |
|
1360 |
+ if(plen >= root->ac_maxdepth) { |
|
1361 |
+ break; |
|
1362 |
+ } else if(plen >= root->ac_mindepth && plen > nzplen) { |
|
1363 |
+ nzplen = plen; |
|
1364 |
+ nzpos = ppos; |
|
1365 |
+ } |
|
1366 |
+ } |
|
1361 | 1367 |
} |
1362 | 1368 |
if(plen >= root->ac_maxdepth && (new->pattern[ppos] || new->pattern[ppos + 1])) |
1363 | 1369 |
break; |
1364 | 1370 |
} |
1371 |
+ if(!new->pattern[ppos] && !new->pattern[ppos + 1] && nzplen) { |
|
1372 |
+ plen = nzplen; |
|
1373 |
+ ppos = nzpos; |
|
1374 |
+ } |
|
1365 | 1375 |
|
1366 | 1376 |
if(plen < root->ac_mindepth) { |
1367 | 1377 |
cli_errmsg("cli_ac_addsig: Can't find a static subpattern of length %u\n", root->ac_mindepth); |