summaryrefslogtreecommitdiffstats
path: root/usr.sbin/gstat
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-09-11 06:52:57 +0000
committerdelphij <delphij@FreeBSD.org>2015-09-11 06:52:57 +0000
commit85e8cd93390eb0f4ee5d7d6ac6b9c1e55f7cee83 (patch)
treeabbb73b2bb4dcc8cd757e5bcfa968d74ef5258b0 /usr.sbin/gstat
parent65d9a559eb7b19c7541531c4e8891e6d45b00ff2 (diff)
downloadFreeBSD-src-85e8cd93390eb0f4ee5d7d6ac6b9c1e55f7cee83.zip
FreeBSD-src-85e8cd93390eb0f4ee5d7d6ac6b9c1e55f7cee83.tar.gz
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). Note that we do not believe there is real-world impact for gstat(8)'s usage because the strings are length checked, and the on-stack buffer belongs to main() and we can expect to have zeros in them. MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/gstat')
-rw-r--r--usr.sbin/gstat/gstat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index d83ef79..8be3775 100644
--- a/usr.sbin/gstat/gstat.c
+++ b/usr.sbin/gstat/gstat.c
@@ -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;
OpenPOWER on IntegriCloud