summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2019-05-20 12:59:02 +0200
committerKarel Zak2019-05-20 12:59:02 +0200
commitaa75c5eb74694ba9ee7f84540943b287fb15a49f (patch)
tree1b923d072eda2a3606dbfea2917f88ef4784a384 /misc-utils
parentvipw: use xstrncpy() (diff)
downloadkernel-qcow2-util-linux-aa75c5eb74694ba9ee7f84540943b287fb15a49f.tar.gz
kernel-qcow2-util-linux-aa75c5eb74694ba9ee7f84540943b287fb15a49f.tar.xz
kernel-qcow2-util-linux-aa75c5eb74694ba9ee7f84540943b287fb15a49f.zip
whereis: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/whereis.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index 21f381321..debd5da55 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -264,8 +264,7 @@ static void dirlist_add_subdir(struct wh_dirlist **ls, int type, const char *dir
DIR *dirp;
struct dirent *dp;
- strncpy(buf, dir, PATH_MAX);
- buf[PATH_MAX - 1] = '\0';
+ xstrncpy(buf, dir, PATH_MAX);
d = strchr(buf, '*');
if (!d)
@@ -452,8 +451,7 @@ static void lookup(const char *pattern, struct wh_dirlist *ls, int want)
/* canonicalize pattern -- remove path suffix etc. */
p = strrchr(pattern, '/');
p = p ? p + 1 : (char *) pattern;
- strncpy(patbuf, p, PATH_MAX);
- patbuf[PATH_MAX - 1] = '\0';
+ xstrncpy(patbuf, p, PATH_MAX);
DBG(SEARCH, ul_debug("lookup dirs for '%s' (%s), want: %s %s %s",
patbuf, pattern,