From owner-svn-src-stable-9@FreeBSD.ORG Sun Jan 1 17:42:03 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FF41106566C; Sun, 1 Jan 2012 17:42:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FF5D8FC14; Sun, 1 Jan 2012 17:42:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q01Hg2W1022999; Sun, 1 Jan 2012 17:42:02 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q01Hg2nC022996; Sun, 1 Jan 2012 17:42:02 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201201011742.q01Hg2nC022996@svn.freebsd.org> From: Dimitry Andric Date: Sun, 1 Jan 2012 17:42:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229177 - stable/9/sbin/dhclient X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jan 2012 17:42:03 -0000 Author: dim Date: Sun Jan 1 17:42:02 2012 New Revision: 229177 URL: http://svn.freebsd.org/changeset/base/229177 Log: MFC r228614: 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 r228615: In sbin/dhclient, since we know the size of the source strings anyway, we might as well use memcpy; strlcpy is really unnecessary here. Modified: stable/9/sbin/dhclient/clparse.c stable/9/sbin/dhclient/parse.c Directory Properties: stable/9/sbin/dhclient/ (props changed) Modified: stable/9/sbin/dhclient/clparse.c ============================================================================== --- stable/9/sbin/dhclient/clparse.c Sun Jan 1 17:37:17 2012 (r229176) +++ stable/9/sbin/dhclient/clparse.c Sun Jan 1 17:42:02 2012 (r229177) @@ -871,6 +871,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. */ @@ -888,10 +889,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); + memcpy(tmp->string, val, valsize); tmp->next = NULL; /* Store this medium at the end of the media list. */ Modified: stable/9/sbin/dhclient/parse.c ============================================================================== --- stable/9/sbin/dhclient/parse.c Sun Jan 1 17:37:17 2012 (r229176) +++ stable/9/sbin/dhclient/parse.c Sun Jan 1 17:42:02 2012 (r229177) @@ -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); + memcpy(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); + memcpy(t, val, valsize); c = cons(t, c); } } while (++count != *max);