diff options
author | dim <dim@FreeBSD.org> | 2011-12-17 01:19:07 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-12-17 01:19:07 +0000 |
commit | b10871ad5bc05f5e1d2d18765cd0728ef81badaa (patch) | |
tree | 72284c3f91f7cef9e3747ae67f25435e7fe8a9af /sbin/dhclient/parse.c | |
parent | 47dd4657eab2f1d399b8ca595dfa14326d41927a (diff) | |
download | FreeBSD-src-b10871ad5bc05f5e1d2d18765cd0728ef81badaa.zip FreeBSD-src-b10871ad5bc05f5e1d2d18765cd0728ef81badaa.tar.gz |
In sbin/dhclient, work around warnings about the size argument to
strlcpy appearing to be the size of the source buffer, instead of the
destination.
MFC after: 1 week
Diffstat (limited to 'sbin/dhclient/parse.c')
-rw-r--r-- | sbin/dhclient/parse.c | 12 |
1 files changed, 8 insertions, 4 deletions
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); |