... | ... |
@@ -1577,6 +1577,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1577 | 1577 |
|
1578 | 1578 |
if(strchr(hexsig, '(')) { |
1579 | 1579 |
char *hexnew, *start, *h, *c; |
1580 |
+ size_t hexnewsz; |
|
1580 | 1581 |
|
1581 | 1582 |
if(hex) { |
1582 | 1583 |
hexcpy = hex; |
... | ... |
@@ -1585,7 +1586,8 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1585 | 1585 |
return CL_EMEM; |
1586 | 1586 |
} |
1587 | 1587 |
|
1588 |
- if(!(hexnew = (char *) cli_calloc(strlen(hexsig) + 1, 1))) { |
|
1588 |
+ hexnewsz = strlen(hexsig) + 1; |
|
1589 |
+ if(!(hexnew = (char *) cli_calloc(1, hexnewsz))) { |
|
1589 | 1590 |
free(new); |
1590 | 1591 |
free(hexcpy); |
1591 | 1592 |
return CL_EMEM; |
... | ... |
@@ -1611,7 +1613,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1611 | 1611 |
pt[-2] = 0; |
1612 | 1612 |
} |
1613 | 1613 |
} |
1614 |
- strcat(hexnew, start); |
|
1614 |
+ cli_strlcat(hexnew, start, hexnewsz); |
|
1615 | 1615 |
|
1616 | 1616 |
if(!(start = strchr(pt, ')'))) { |
1617 | 1617 |
mpool_free(root->mempool, newspecial); |
... | ... |
@@ -1654,7 +1656,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1654 | 1654 |
continue; |
1655 | 1655 |
} |
1656 | 1656 |
} |
1657 |
- strcat(hexnew, "()"); |
|
1657 |
+ cli_strlcat(hexnew, "()", hexnewsz); |
|
1658 | 1658 |
new->special++; |
1659 | 1659 |
newtable = (struct cli_ac_special **) mpool_realloc(root->mempool, new->special_table, new->special * sizeof(struct cli_ac_special *)); |
1660 | 1660 |
if(!newtable) { |
... | ... |
@@ -1746,7 +1748,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1746 | 1746 |
} |
1747 | 1747 |
|
1748 | 1748 |
if(start) |
1749 |
- strcat(hexnew, start); |
|
1749 |
+ cli_strlcat(hexnew, start, hexnewsz); |
|
1750 | 1750 |
|
1751 | 1751 |
hex = hexnew; |
1752 | 1752 |
free(hexcpy); |
... | ... |
@@ -697,12 +697,12 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first |
697 | 697 |
break; |
698 | 698 |
} |
699 | 699 |
} else if(line != NULL) { |
700 |
- fulllinelength += strlen(line); |
|
700 |
+ fulllinelength += strlen(line) + 1; |
|
701 | 701 |
ptr = cli_realloc(fullline, fulllinelength); |
702 | 702 |
if(ptr == NULL) |
703 | 703 |
continue; |
704 | 704 |
fullline = ptr; |
705 |
- strcat(fullline, line); |
|
705 |
+ cli_strlcat(fullline, line, fulllinelength); |
|
706 | 706 |
} |
707 | 707 |
|
708 | 708 |
assert(fullline != NULL); |
... | ... |
@@ -902,12 +902,12 @@ parseEmailHeaders(message *m, const table_t *rfc821) |
902 | 902 |
fullline = cli_strdup(line); |
903 | 903 |
fulllinelength = strlen(line) + 1; |
904 | 904 |
} else if(line) { |
905 |
- fulllinelength += strlen(line); |
|
905 |
+ fulllinelength += strlen(line) + 1; |
|
906 | 906 |
ptr = cli_realloc(fullline, fulllinelength); |
907 | 907 |
if(ptr == NULL) |
908 | 908 |
continue; |
909 | 909 |
fullline = ptr; |
910 |
- strcat(fullline, line); |
|
910 |
+ cli_strlcat(fullline, line, fulllinelength); |
|
911 | 911 |
} |
912 | 912 |
assert(fullline != NULL); |
913 | 913 |
|
... | ... |
@@ -1456,6 +1456,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re |
1456 | 1456 |
*/ |
1457 | 1457 |
while(t_line && next_is_folded_header(t_line)) { |
1458 | 1458 |
const char *data; |
1459 |
+ size_t datasz; |
|
1459 | 1460 |
|
1460 | 1461 |
t_line = t_line->t_next; |
1461 | 1462 |
|
... | ... |
@@ -1474,14 +1475,14 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re |
1474 | 1474 |
break; |
1475 | 1475 |
} |
1476 | 1476 |
|
1477 |
- ptr = cli_realloc(fullline, |
|
1478 |
- strlen(fullline) + strlen(data) + 1); |
|
1477 |
+ datasz = strlen(fullline) + strlen(data) + 1; |
|
1478 |
+ ptr = cli_realloc(fullline, datasz); |
|
1479 | 1479 |
|
1480 | 1480 |
if(ptr == NULL) |
1481 | 1481 |
break; |
1482 | 1482 |
|
1483 | 1483 |
fullline = ptr; |
1484 |
- strcat(fullline, data); |
|
1484 |
+ cli_strlcat(fullline, data, datasz); |
|
1485 | 1485 |
|
1486 | 1486 |
/*quotes = count_quotes(data);*/ |
1487 | 1487 |
} |
... | ... |
@@ -480,6 +480,7 @@ messageAddArguments(message *m, const char *s) |
480 | 480 |
while(*string) { |
481 | 481 |
const char *key, *cptr; |
482 | 482 |
char *data, *field; |
483 |
+ size_t datasz=0; |
|
483 | 484 |
|
484 | 485 |
if(isspace(*string & 0xff) || (*string == ';')) { |
485 | 486 |
string++; |
... | ... |
@@ -592,12 +593,14 @@ messageAddArguments(message *m, const char *s) |
592 | 592 |
|
593 | 593 |
*ptr = '\0'; |
594 | 594 |
|
595 |
+ datasz = strlen(kcopy) + strlen(data) + 2; |
|
595 | 596 |
field = cli_realloc(kcopy, strlen(kcopy) + strlen(data) + 2); |
596 | 597 |
if(field) { |
597 |
- strcat(field, "="); |
|
598 |
- strcat(field, data); |
|
599 |
- } else |
|
598 |
+ cli_strlcat(field, "=", datasz); |
|
599 |
+ cli_strlcat(field, data, datasz); |
|
600 |
+ } else { |
|
600 | 601 |
free(kcopy); |
602 |
+ } |
|
601 | 603 |
free(data); |
602 | 604 |
} else { |
603 | 605 |
size_t len; |
... | ... |
@@ -117,7 +117,7 @@ int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hex |
117 | 117 |
int ret, asterisk = 0, range; |
118 | 118 |
unsigned int i, j, hexlen, parts = 0; |
119 | 119 |
int mindist = 0, maxdist = 0, error = 0; |
120 |
- |
|
120 |
+ size_t hexcpysz; |
|
121 | 121 |
|
122 | 122 |
hexlen = strlen(hexsig); |
123 | 123 |
if (hexsig[0] == '$') { |
... | ... |
@@ -165,18 +165,19 @@ int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hex |
165 | 165 |
} |
166 | 166 |
if((wild = strchr(hexsig, '{'))) { |
167 | 167 |
if(sscanf(wild, "%c%u%c", &l, &range, &r) == 3 && l == '{' && r == '}' && range > 0 && range < 128) { |
168 |
- hexcpy = cli_calloc(hexlen + 2 * range, sizeof(char)); |
|
168 |
+ hexcpysz = hexlen + 2 * range; |
|
169 |
+ hexcpy = cli_calloc(1, hexcpysz); |
|
169 | 170 |
if(!hexcpy) |
170 | 171 |
return CL_EMEM; |
171 | 172 |
strncpy(hexcpy, hexsig, wild - hexsig); |
172 | 173 |
for(i = 0; i < (unsigned int) range; i++) |
173 |
- strcat(hexcpy, "??"); |
|
174 |
+ cli_strlcat(hexcpy, "??", hexcpysz); |
|
174 | 175 |
if(!(wild = strchr(wild, '}'))) { |
175 | 176 |
cli_errmsg("cli_parse_add(): Problem adding signature: missing bracket\n"); |
176 | 177 |
free(hexcpy); |
177 | 178 |
return CL_EMALFDB; |
178 | 179 |
} |
179 |
- strcat(hexcpy, ++wild); |
|
180 |
+ cli_strlcat(hexcpy, ++wild, hexcpysz); |
|
180 | 181 |
ret = cli_parse_add(root, virname, hexcpy, rtype, type, offset, target, lsigid, options); |
181 | 182 |
free(hexcpy); |
182 | 183 |
return ret; |