Date: Fri, 25 Sep 2015 01:17:52 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r288206 - stable/9/usr.sbin/gstat Message-ID: <201509250117.t8P1HqwO046573@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Fri Sep 25 01:17:52 2015 New Revision: 288206 URL: https://svnweb.freebsd.org/changeset/base/288206 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/9/usr.sbin/gstat/gstat.c Directory Properties: stable/9/usr.sbin/gstat/ (props changed) Modified: stable/9/usr.sbin/gstat/gstat.c ============================================================================== --- stable/9/usr.sbin/gstat/gstat.c Fri Sep 25 01:17:24 2015 (r288205) +++ stable/9/usr.sbin/gstat/gstat.c Fri Sep 25 01:17:52 2015 (r288206) @@ -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 'I': p = NULL; @@ -210,7 +210,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) @@ -382,7 +382,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'; /* @@ -399,7 +399,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509250117.t8P1HqwO046573>