diff options
-rw-r--r-- | sbin/dhclient/clparse.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 7c1e74f..fea935a 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -873,6 +873,7 @@ parse_string_list(FILE *cfile, struct string_list **lp, int multiple) { int token; char *val; + size_t valsize; struct string_list *cur, *tmp; /* Find the last medium in the media list. */ @@ -890,10 +891,11 @@ parse_string_list(FILE *cfile, struct string_list **lp, int multiple) return; } - tmp = new_string_list(strlen(val) + 1); + valsize = strlen(val) + 1; + tmp = new_string_list(valsize); if (tmp == NULL) error("no memory for string list entry."); - strlcpy(tmp->string, val, strlen(val) + 1); + strlcpy(tmp->string, val, valsize); tmp->next = NULL; /* Store this medium at the end of the media list. */ diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index 6a54fd0..13e8373 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -116,6 +116,7 @@ char * parse_string(FILE *cfile) { char *val, *s; + size_t valsize; int token; token = next_token(&val, cfile); @@ -124,10 +125,11 @@ parse_string(FILE *cfile) skip_to_semi(cfile); return (NULL); } - s = malloc(strlen(val) + 1); + valsize = strlen(val) + 1; + s = malloc(valsize); if (!s) error("no memory for string %s.", val); - strlcpy(s, val, strlen(val) + 1); + strlcpy(s, val, valsize); if (!parse_semi(cfile)) return (NULL); @@ -242,6 +244,7 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, unsigned char *bufp = buf, *s = NULL; int token, count = 0; char *val, *t; + size_t valsize; pair c = NULL; if (!bufp && *max) { @@ -288,10 +291,11 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, convert_num(s, val, base, size); s += size / 8; } else { - t = malloc(strlen(val) + 1); + valsize = strlen(val) + 1; + t = malloc(valsize); if (!t) error("no temp space for number."); - strlcpy(t, val, strlen(val) + 1); + strlcpy(t, val, valsize); c = cons(t, c); } } while (++count != *max); |