... | ... |
@@ -433,10 +433,10 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) |
433 | 433 |
|
434 | 434 |
struct choice choices[MAX_CHOICES]; |
435 | 435 |
unsigned choices_cnt = 0; |
436 |
- unsigned prefix_len = pat->prefix_length; |
|
436 |
+ unsigned prefix_len = pat->prefix_length[0]; |
|
437 | 437 |
unsigned speci; |
438 | 438 |
|
439 |
- j = MIN(prefix_len + pat->length, MAXPATLEN); |
|
439 |
+ j = MIN(prefix_len + pat->length[0], MAXPATLEN); |
|
440 | 440 |
for(i=0;i<j;i++) { |
441 | 441 |
const uint16_t p = i < prefix_len ? pat->prefix[i] : pat->pattern[i - prefix_len]; |
442 | 442 |
if ((p&CLI_MATCH_WILDCARD) != CLI_MATCH_CHAR) |
... | ... |
@@ -119,8 +119,8 @@ static inline int insert_list(struct cli_matcher *root, struct cli_ac_patt *patt |
119 | 119 |
php = ph->me; |
120 | 120 |
if(!ph_add_after && php->partno <= pattern->partno && (!ph->next || ph->next->me->partno > pattern->partno)) |
121 | 121 |
ph_add_after = ph; |
122 |
- if((php->length == pattern->length) && (php->prefix_length == pattern->prefix_length) && (php->ch[0] == pattern->ch[0]) && (php->ch[1] == pattern->ch[1]) && (php->boundary == pattern->boundary)) { |
|
123 |
- if(!memcmp(php->pattern, pattern->pattern, php->length * sizeof(uint16_t)) && !memcmp(php->prefix, pattern->prefix, php->prefix_length * sizeof(uint16_t))) { |
|
122 |
+ if((php->length[0] == pattern->length[0]) && (php->prefix_length[0] == pattern->prefix_length[0]) && (php->ch[0] == pattern->ch[0]) && (php->ch[1] == pattern->ch[1]) && (php->boundary == pattern->boundary)) { |
|
123 |
+ if(!memcmp(php->pattern, pattern->pattern, php->length[0] * sizeof(uint16_t)) && !memcmp(php->prefix, pattern->prefix, php->prefix_length[0] * sizeof(uint16_t))) { |
|
124 | 124 |
if(!php->special && !pattern->special) { |
125 | 125 |
match = 1; |
126 | 126 |
} else if(php->special == pattern->special) { |
... | ... |
@@ -308,7 +308,7 @@ int cli_ac_addpatt(struct cli_matcher *root, struct cli_ac_patt *pattern) |
308 | 308 |
{ |
309 | 309 |
struct cli_ac_node *pt; |
310 | 310 |
struct cli_ac_patt **newtable; |
311 |
- uint16_t len = MIN(root->ac_maxdepth, pattern->length); |
|
311 |
+ uint16_t len = MIN(root->ac_maxdepth, pattern->length[0]); |
|
312 | 312 |
uint8_t i; |
313 | 313 |
|
314 | 314 |
for(i = 0; i < len; i++) { |
... | ... |
@@ -1036,7 +1036,7 @@ static int ac_findmatch_branch(const unsigned char *buffer, uint32_t offset, uin |
1036 | 1036 |
uint16_t wc, i; |
1037 | 1037 |
|
1038 | 1038 |
match = 1; |
1039 |
- for(i = pattoffset; i < pattern->length && bp < length; i++) { |
|
1039 |
+ for(i = pattoffset; i < pattern->length[0] && bp < length; i++) { |
|
1040 | 1040 |
AC_MATCH_CHAR(pattern->pattern[i],buffer[bp]); |
1041 | 1041 |
if (!match) |
1042 | 1042 |
return 0; |
... | ... |
@@ -1145,10 +1145,10 @@ static int ac_findmatch_branch(const unsigned char *buffer, uint32_t offset, uin |
1145 | 1145 |
|
1146 | 1146 |
if(pattern->prefix) { |
1147 | 1147 |
specialcnt = 0; |
1148 |
- bp = offset - pattern->prefix_length; |
|
1148 |
+ bp = offset - pattern->prefix_length[0]; |
|
1149 | 1149 |
match = 1; |
1150 | 1150 |
|
1151 |
- for(i = 0; i < pattern->prefix_length; i++) { |
|
1151 |
+ for(i = 0; i < pattern->prefix_length[0]; i++) { |
|
1152 | 1152 |
AC_MATCH_CHAR(pattern->prefix[i],buffer[bp]); |
1153 | 1153 |
if(!match) |
1154 | 1154 |
return 0; |
... | ... |
@@ -1158,7 +1158,7 @@ static int ac_findmatch_branch(const unsigned char *buffer, uint32_t offset, uin |
1158 | 1158 |
} |
1159 | 1159 |
|
1160 | 1160 |
if(!(pattern->ch[0] & CLI_MATCH_IGNORE)) { |
1161 |
- bp = offset - pattern->prefix_length; |
|
1161 |
+ bp = offset - pattern->prefix_length[0]; |
|
1162 | 1162 |
if(pattern->ch_mindist[0] + (uint32_t) 1 > bp) |
1163 | 1163 |
return 0; |
1164 | 1164 |
|
... | ... |
@@ -1186,7 +1186,7 @@ inline static int ac_findmatch(const unsigned char *buffer, uint32_t offset, uin |
1186 | 1186 |
int match; |
1187 | 1187 |
uint16_t specialcnt = pattern->special_pattern; |
1188 | 1188 |
|
1189 |
- if((offset + pattern->length > length) || (pattern->prefix_length > offset)) |
|
1189 |
+ if((offset + pattern->length[0] > length) || (pattern->prefix_length[0] > offset)) |
|
1190 | 1190 |
return 0; |
1191 | 1191 |
|
1192 | 1192 |
match = ac_findmatch_branch(buffer, offset, offset+pattern->depth, fileoffset, length, pattern, pattern->depth, specialcnt, end); |
... | ... |
@@ -1360,7 +1360,7 @@ int cli_ac_caloff(const struct cli_matcher *root, struct cli_ac_data *data, cons |
1360 | 1360 |
} else if((ret = cli_caloff(NULL, info, root->type, patt->offdata, &data->offset[patt->offset_min], &data->offset[patt->offset_max]))) { |
1361 | 1361 |
cli_errmsg("cli_ac_caloff: Can't calculate relative offset in signature for %s\n", patt->virname); |
1362 | 1362 |
return ret; |
1363 |
- } else if((data->offset[patt->offset_min] != CLI_OFF_NONE) && (data->offset[patt->offset_min] + patt->length > info->fsize)) { |
|
1363 |
+ } else if((data->offset[patt->offset_min] != CLI_OFF_NONE) && (data->offset[patt->offset_min] + patt->length[0] > info->fsize)) { |
|
1364 | 1364 |
data->offset[patt->offset_min] = CLI_OFF_NONE; |
1365 | 1365 |
} |
1366 | 1366 |
} |
... | ... |
@@ -1611,7 +1611,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1611 | 1611 |
pattN = pattN->next; |
1612 | 1612 |
continue; |
1613 | 1613 |
} |
1614 |
- realoff = offset + bp - patt->prefix_length; |
|
1614 |
+ realoff = offset + bp - patt->prefix_length[0]; |
|
1615 | 1615 |
if(patt->offdata[0] == CLI_OFF_ABSOLUTE) { |
1616 | 1616 |
if(patt->offset_max < realoff || patt->offset_min > realoff) { |
1617 | 1617 |
pattN = pattN->next; |
... | ... |
@@ -1626,7 +1626,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1626 | 1626 |
} |
1627 | 1627 |
|
1628 | 1628 |
ptN = pattN; |
1629 |
- if(ac_findmatch(buffer, bp, offset + bp - patt->prefix_length, length, patt, &matchend)) { |
|
1629 |
+ if(ac_findmatch(buffer, bp, offset + bp - patt->prefix_length[0], length, patt, &matchend)) { |
|
1630 | 1630 |
while(ptN) { |
1631 | 1631 |
pt = ptN->me; |
1632 | 1632 |
if(pt->partno > mdata->min_partno) |
... | ... |
@@ -1637,7 +1637,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1637 | 1637 |
continue; |
1638 | 1638 |
} |
1639 | 1639 |
|
1640 |
- realoff = offset + bp - pt->prefix_length; |
|
1640 |
+ realoff = offset + bp - pt->prefix_length[0]; |
|
1641 | 1641 |
if(pt->offdata[0] == CLI_OFF_VERSION) { |
1642 | 1642 |
if(!cli_hashset_contains_maybe_noalloc(mdata->vinfo, realoff)) { |
1643 | 1643 |
ptN = ptN->next_same; |
... | ... |
@@ -2621,13 +2621,13 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
2621 | 2621 |
return CL_EMALFDB; |
2622 | 2622 |
} |
2623 | 2623 |
|
2624 |
- new->length = strlen(hex ? hex : hexsig) / 2; |
|
2624 |
+ new->length[0] = strlen(hex ? hex : hexsig) / 2; |
|
2625 | 2625 |
free(hex); |
2626 | 2626 |
|
2627 | 2627 |
new->sigopts = sigopts; |
2628 | 2628 |
/* setting nocase match */ |
2629 | 2629 |
if (sigopts & ACPATT_OPTION_NOCASE) { |
2630 |
- for (i = 0; i < new->length; ++i) |
|
2630 |
+ for (i = 0; i < new->length[0]; ++i) |
|
2631 | 2631 |
if ((new->pattern[i] & CLI_MATCH_METADATA) == CLI_MATCH_CHAR) { |
2632 | 2632 |
new->pattern[i] = cli_nocase(new->pattern[i] & 0xff); |
2633 | 2633 |
new->pattern[i] += CLI_MATCH_NOCASE; |
... | ... |
@@ -2647,7 +2647,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
2647 | 2647 |
/* TODO: should this affect maxpatlen? */ |
2648 | 2648 |
} |
2649 | 2649 |
|
2650 |
- for(i = 0; i < root->ac_maxdepth && i < new->length; i++) { |
|
2650 |
+ for(i = 0; i < root->ac_maxdepth && i < new->length[0]; i++) { |
|
2651 | 2651 |
if(new->pattern[i] & CLI_MATCH_WILDCARD) { |
2652 | 2652 |
wprefix = 1; |
2653 | 2653 |
break; |
... | ... |
@@ -2658,9 +2658,9 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
2658 | 2658 |
} |
2659 | 2659 |
|
2660 | 2660 |
if(wprefix || zprefix) { |
2661 |
- pend = new->length - root->ac_mindepth + 1; |
|
2661 |
+ pend = new->length[0] - root->ac_mindepth + 1; |
|
2662 | 2662 |
for(i = 0; i < pend; i++) { |
2663 |
- for(j = i; j < i + root->ac_maxdepth && j < new->length; j++) { |
|
2663 |
+ for(j = i; j < i + root->ac_maxdepth && j < new->length[0]; j++) { |
|
2664 | 2664 |
if(new->pattern[j] & CLI_MATCH_WILDCARD) { |
2665 | 2665 |
break; |
2666 | 2666 |
} else { |
... | ... |
@@ -2698,17 +2698,17 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
2698 | 2698 |
} |
2699 | 2699 |
|
2700 | 2700 |
new->prefix = new->pattern; |
2701 |
- new->prefix_length = ppos; |
|
2701 |
+ new->prefix_length[0] = ppos; |
|
2702 | 2702 |
new->pattern = &new->prefix[ppos]; |
2703 |
- new->length -= ppos; |
|
2703 |
+ new->length[0] -= ppos; |
|
2704 | 2704 |
|
2705 |
- for(i = 0; i < new->prefix_length; i++) |
|
2705 |
+ for(i = 0; i < new->prefix_length[0]; i++) |
|
2706 | 2706 |
if((new->prefix[i] & CLI_MATCH_WILDCARD) == CLI_MATCH_SPECIAL) |
2707 | 2707 |
new->special_pattern++; |
2708 | 2708 |
} |
2709 | 2709 |
|
2710 |
- if(new->length + new->prefix_length > root->maxpatlen) |
|
2711 |
- root->maxpatlen = new->length + new->prefix_length; |
|
2710 |
+ if(new->length[0] + new->prefix_length[0] > root->maxpatlen) |
|
2711 |
+ root->maxpatlen = new->length[0] + new->prefix_length[0]; |
|
2712 | 2712 |
|
2713 | 2713 |
new->virname = cli_mpool_virname(root->mempool, virname, options & CL_DB_OFFICIAL); |
2714 | 2714 |
if(!new->virname) { |
... | ... |
@@ -334,10 +334,10 @@ int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hex |
334 | 334 |
patt->ch_mindist[0] = smin; |
335 | 335 |
patt->ch_maxdist[0] = smax; |
336 | 336 |
patt->sigid = tid; |
337 |
- patt->length = root->ac_mindepth; |
|
337 |
+ patt->length[0] = root->ac_mindepth; |
|
338 | 338 |
|
339 | 339 |
/* dummy */ |
340 |
- patt->pattern = mpool_calloc(root->mempool, patt->length, sizeof(*patt->pattern)); |
|
340 |
+ patt->pattern = mpool_calloc(root->mempool, patt->length[0], sizeof(*patt->pattern)); |
|
341 | 341 |
if (!patt->pattern) { |
342 | 342 |
free(patt); |
343 | 343 |
return CL_EMEM; |
... | ... |
@@ -584,11 +584,11 @@ static int add_newsuffix(struct regex_matcher *matcher, struct regex_list *info, |
584 | 584 |
new->mindist = 0; |
585 | 585 |
new->maxdist = 0; |
586 | 586 |
new->offset_min = CLI_OFF_ANY; |
587 |
- new->length = len; |
|
587 |
+ new->length[0] = len; |
|
588 | 588 |
|
589 | 589 |
new->ch[0] = new->ch[1] |= CLI_MATCH_IGNORE; |
590 |
- if(new->length > root->maxpatlen) |
|
591 |
- root->maxpatlen = new->length; |
|
590 |
+ if(new->length[0] > root->maxpatlen) |
|
591 |
+ root->maxpatlen = new->length[0]; |
|
592 | 592 |
|
593 | 593 |
new->pattern = mpool_malloc(matcher->mempool, sizeof(new->pattern[0])*len); |
594 | 594 |
if(!new->pattern) { |