From owner-svn-src-head@FreeBSD.ORG Fri Oct 17 21:21:14 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8E111065678; Fri, 17 Oct 2008 21:21:14 +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 C74AB8FC0C; Fri, 17 Oct 2008 21:21:14 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9HLLEbE098196; Fri, 17 Oct 2008 21:21:14 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9HLLETA098194; Fri, 17 Oct 2008 21:21:14 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200810172121.m9HLLETA098194@svn.freebsd.org> From: Xin LI Date: Fri, 17 Oct 2008 21:21:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183989 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2008 21:21:15 -0000 Author: delphij Date: Fri Oct 17 21:21:14 2008 New Revision: 183989 URL: http://svn.freebsd.org/changeset/base/183989 Log: Use strlcpy() when we mean it. Modified: head/lib/libutil/login_times.c head/lib/libutil/logwtmp.c head/lib/libutil/realhostname.c Modified: head/lib/libutil/login_times.c ============================================================================== --- head/lib/libutil/login_times.c Fri Oct 17 21:14:50 2008 (r183988) +++ head/lib/libutil/login_times.c Fri Oct 17 21:21:14 2008 (r183989) @@ -72,8 +72,7 @@ parse_lt(const char * str) char buf[64]; /* Make local copy and force lowercase to simplify parsing */ - p = strncpy(buf, str, sizeof buf); - buf[sizeof buf - 1] = '\0'; + p = strlcpy(buf, str, sizeof buf); for (i = 0; buf[i]; i++) buf[i] = (char)tolower(buf[i]); Modified: head/lib/libutil/logwtmp.c ============================================================================== --- head/lib/libutil/logwtmp.c Fri Oct 17 21:14:50 2008 (r183988) +++ head/lib/libutil/logwtmp.c Fri Oct 17 21:21:14 2008 (r183989) @@ -59,8 +59,7 @@ logwtmp(const char *line, const char *na char fullhost[MAXHOSTNAMELEN]; int fd; - strncpy(fullhost, host, sizeof(fullhost) - 1); - fullhost[sizeof(fullhost) - 1] = '\0'; + strlcpy(fullhost, host, sizeof(fullhost)); trimdomain(fullhost, UT_HOSTSIZE); host = fullhost; Modified: head/lib/libutil/realhostname.c ============================================================================== --- head/lib/libutil/realhostname.c Fri Oct 17 21:14:50 2008 (r183988) +++ head/lib/libutil/realhostname.c Fri Oct 17 21:21:14 2008 (r183989) @@ -61,8 +61,7 @@ realhostname(char *host, size_t hsize, c if (strlen(trimmed) <= hsize) { char lookup[MAXHOSTNAMELEN]; - strncpy(lookup, hp->h_name, sizeof(lookup) - 1); - lookup[sizeof(lookup) - 1] = '\0'; + strlcpy(lookup, hp->h_name, sizeof(lookup)); hp = gethostbyname(lookup); if (hp == NULL) result = HOSTNAME_INVALIDNAME;