when patt->partno > mdata->min_partno matching has to continue at the faillist.
Török Edvin authored on 2011/12/12 23:51:59... | ... |
@@ -357,9 +357,9 @@ static int ac_maketrans(struct cli_matcher *root) |
357 | 357 |
if (list) { |
358 | 358 |
while (list->next) list = list->next; |
359 | 359 |
list->next = child->fail->list; |
360 |
- } |
|
360 |
+ } else |
|
361 |
+ child->list = child->fail->list; |
|
361 | 362 |
child->trans = child->fail->trans; |
362 |
- child->fail = NULL; |
|
363 | 363 |
} else { |
364 | 364 |
if((ret = bfs_enqueue(&bfs, &bfs_last, child)) != 0) |
365 | 365 |
return ret; |
... | ... |
@@ -470,7 +470,9 @@ void cli_ac_free(struct cli_matcher *root) |
470 | 470 |
mpool_free(root->mempool, root->ac_reloff); |
471 | 471 |
|
472 | 472 |
for(i = 0; i < root->ac_nodes; i++) { |
473 |
- if(!IS_LEAF(root->ac_nodetable[i]) && root->ac_nodetable[i]->fail) |
|
473 |
+ if(!IS_LEAF(root->ac_nodetable[i]) && |
|
474 |
+ root->ac_nodetable[i]->fail && |
|
475 |
+ root->ac_nodetable[i]->trans != root->ac_nodetable[i]->fail->trans) |
|
474 | 476 |
mpool_free(root->mempool, root->ac_nodetable[i]->trans); |
475 | 477 |
mpool_free(root->mempool, root->ac_nodetable[i]); |
476 | 478 |
} |
... | ... |
@@ -1180,11 +1182,13 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1180 | 1180 |
current = current->trans[buffer[i]]; |
1181 | 1181 |
|
1182 | 1182 |
if(UNLIKELY(IS_FINAL(current))) { |
1183 |
+ struct cli_ac_patt *faillist = current->fail->list; |
|
1183 | 1184 |
patt = current->list; |
1184 | 1185 |
while(patt) { |
1185 | 1186 |
if(patt->partno > mdata->min_partno) { |
1186 |
- patt = NULL; |
|
1187 |
- break; |
|
1187 |
+ patt = faillist; |
|
1188 |
+ faillist = NULL; |
|
1189 |
+ continue; |
|
1188 | 1190 |
} |
1189 | 1191 |
bp = i + 1 - patt->depth; |
1190 | 1192 |
if(patt->offdata[0] != CLI_OFF_VERSION && patt->offdata[0] != CLI_OFF_MACRO && !patt->next_same && (patt->offset_min != CLI_OFF_ANY) && (!patt->sigid || patt->partno == 1)) { |