From aa75c5eb74694ba9ee7f84540943b287fb15a49f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 20 May 2019 12:59:02 +0200 Subject: whereis: use xstrncpy() Signed-off-by: Karel Zak --- misc-utils/whereis.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'misc-utils') 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, -- cgit v1.2.3-55-g7522