Date: Sat, 17 Dec 2011 01:19:07 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r228614 - head/sbin/dhclient Message-ID: <201112170119.pBH1J7BV036204@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Dec 17 01:19:07 2011 New Revision: 228614 URL: http://svn.freebsd.org/changeset/base/228614 Log: 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 Modified: head/sbin/dhclient/clparse.c head/sbin/dhclient/parse.c Modified: head/sbin/dhclient/clparse.c ============================================================================== --- head/sbin/dhclient/clparse.c Sat Dec 17 01:02:56 2011 (r228613) +++ head/sbin/dhclient/clparse.c Sat Dec 17 01:19:07 2011 (r228614) @@ -873,6 +873,7 @@ parse_string_list(FILE *cfile, struct st { 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 st 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. */ Modified: head/sbin/dhclient/parse.c ============================================================================== --- head/sbin/dhclient/parse.c Sat Dec 17 01:02:56 2011 (r228613) +++ head/sbin/dhclient/parse.c Sat Dec 17 01:19:07 2011 (r228614) @@ -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, uns 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, uns 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112170119.pBH1J7BV036204>