diff options
author | Karel Zak | 2019-05-20 12:59:02 +0200 |
---|---|---|
committer | Karel Zak | 2019-05-20 12:59:02 +0200 |
commit | aa75c5eb74694ba9ee7f84540943b287fb15a49f (patch) | |
tree | 1b923d072eda2a3606dbfea2917f88ef4784a384 /misc-utils | |
parent | vipw: use xstrncpy() (diff) | |
download | kernel-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.c | 6 |
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, |