From owner-svn-src-stable-8@FreeBSD.ORG Wed Aug 10 08:52:27 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DECFC106566B; Wed, 10 Aug 2011 08:52:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CED798FC18; Wed, 10 Aug 2011 08:52:27 +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 p7A8qRha033187; Wed, 10 Aug 2011 08:52:27 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7A8qRDt033185; Wed, 10 Aug 2011 08:52:27 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201108100852.p7A8qRDt033185@svn.freebsd.org> From: Xin LI Date: Wed, 10 Aug 2011 08:52:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224753 - stable/8/usr.bin/rpcgen X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 08:52:28 -0000 Author: delphij Date: Wed Aug 10 08:52:27 2011 New Revision: 224753 URL: http://svn.freebsd.org/changeset/base/224753 Log: MFC r223922: Use strlcpy(). Modified: stable/8/usr.bin/rpcgen/rpc_scan.c Directory Properties: stable/8/usr.bin/rpcgen/ (props changed) Modified: stable/8/usr.bin/rpcgen/rpc_scan.c ============================================================================== --- stable/8/usr.bin/rpcgen/rpc_scan.c Wed Aug 10 08:40:59 2011 (r224752) +++ stable/8/usr.bin/rpcgen/rpc_scan.c Wed Aug 10 08:52:27 2011 (r224753) @@ -329,10 +329,9 @@ findstrconst(char **str, const char **va error("unterminated string constant"); } p++; - size = p - *str; - tmp = xmalloc(size + 1); - (void) strncpy(tmp, *str, size); - tmp[size] = 0; + size = p - *str + 1; + tmp = xmalloc(size); + (void) strlcpy(tmp, *str, size); *val = tmp; *str = p; } @@ -352,13 +351,12 @@ findchrconst(char **str, const char **va error("unterminated string constant"); } p++; - size = p - *str; - if (size != 3) { + size = p - *str + 1; + if (size != 4) { error("empty char string"); } - tmp = xmalloc(size + 1); - (void) strncpy(tmp, *str, size); - tmp[size] = 0; + tmp = xmalloc(size); + (void) strlcpy(tmp, *str, size); *val = tmp; *str = p; } @@ -381,10 +379,9 @@ findconst(char **str, const char **val) p++; } while (isdigit(*p)); } - size = p - *str; - tmp = xmalloc(size + 1); - (void) strncpy(tmp, *str, size); - tmp[size] = 0; + size = p - *str + 1; + tmp = xmalloc(size); + (void) strlcpy(tmp, *str, size); *val = tmp; *str = p; } @@ -438,8 +435,7 @@ findkind(char **mark, token *tokp) tokp->kind = TOK_IDENT; for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); tmp = xmalloc(len + 1); - (void) strncpy(tmp, str, len); - tmp[len] = 0; + (void) strlcpy(tmp, str, len + 1); tokp->str = tmp; *mark = str + len; }