From: Sami Kerola Date: Sun, 13 Jul 2014 17:13:38 +0000 (+0100) Subject: whereis: avoid printing uninitialized string X-Git-Tag: v2.25~75^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46ed18361327845670316ecc6ab13afba7cceb43;p=thirdparty%2Futil-linux.git whereis: avoid printing uninitialized string The patbuf[] needs to be filled before print out. Signed-off-by: Sami Kerola --- diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index ba83b159bd..5339abab27 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -408,13 +408,12 @@ static void lookup(const char *pattern, struct wh_dirlist *ls, int want) int count = 0; char *wait = NULL, *p; - DBG(printf("lookup dirs for '%s' (%s)", patbuf, pattern)); - /* 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'; + DBG(printf("lookup dirs for '%s' (%s)", patbuf, pattern)); p = strrchr(patbuf, '.'); if (p) *p = '\0';