From owner-svn-src-stable-10@freebsd.org Fri Sep 25 01:17:25 2015 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 705E7A095AC; Fri, 25 Sep 2015 01:17:25 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 606A81284; Fri, 25 Sep 2015 01:17:25 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8P1HPVU046504; Fri, 25 Sep 2015 01:17:25 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8P1HP0h046503; Fri, 25 Sep 2015 01:17:25 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201509250117.t8P1HP0h046503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Fri, 25 Sep 2015 01:17:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r288205 - stable/10/usr.sbin/gstat X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 01:17:25 -0000 Author: delphij Date: Fri Sep 25 01:17:24 2015 New Revision: 288205 URL: https://svnweb.freebsd.org/changeset/base/288205 Log: MFC r287650: Use strlcpy() in favor of strncpy() as it's defined to have a nul character at the end of string buffer, and the code context do expects this to behave correctly (e.g. strchr). Modified: stable/10/usr.sbin/gstat/gstat.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/gstat/gstat.c ============================================================================== --- stable/10/usr.sbin/gstat/gstat.c Fri Sep 25 01:05:44 2015 (r288204) +++ stable/10/usr.sbin/gstat/gstat.c Fri Sep 25 01:17:24 2015 (r288205) @@ -124,7 +124,7 @@ main(int argc, char **argv) if (regcomp(&f_re, optarg, REG_EXTENDED) != 0) errx(EX_USAGE, "Invalid filter - see re_format(7)"); - strncpy(f_s, optarg, sizeof(f_s)); + strlcpy(f_s, optarg, sizeof(f_s)); break; case 'o': flag_o = 1; @@ -216,7 +216,7 @@ main(int argc, char **argv) getyx(stdscr, cury, curx); getmaxyx(stdscr, maxy, maxx); } - strncpy(pf_s, f_s, sizeof(pf_s)); + strlcpy(pf_s, f_s, sizeof(pf_s)); max_flen = maxx - curx - 1; if ((int)strlen(f_s) > max_flen && max_flen >= 0) { if (max_flen > 3) @@ -406,7 +406,7 @@ main(int argc, char **argv) err(1, "el_gets"); if (line_len > 1) history(hist, &hist_ev, H_ENTER, line); - strncpy(tmp_f_s, line, sizeof(f_s)); + strlcpy(tmp_f_s, line, sizeof(f_s)); if ((p = strchr(tmp_f_s, '\n')) != NULL) *p = '\0'; /* @@ -423,7 +423,7 @@ main(int argc, char **argv) refresh(); sleep(1); } else { - strncpy(f_s, tmp_f_s, sizeof(f_s)); + strlcpy(f_s, tmp_f_s, sizeof(f_s)); f_re = tmp_f_re; } break;