summaryrefslogtreecommitdiffstats
path: root/misc-utils/whereis.c
diff options
context:
space:
mode:
authorSami Kerola2014-07-13 19:13:38 +0200
committerSami Kerola2014-07-13 19:35:38 +0200
commit46ed18361327845670316ecc6ab13afba7cceb43 (patch)
tree0f39645b2e545d8b1f8e1d93de3c7a37dffb4de3 /misc-utils/whereis.c
parentsetpriv: avoid alloca() use xmalloc() instead (diff)
downloadkernel-qcow2-util-linux-46ed18361327845670316ecc6ab13afba7cceb43.tar.gz
kernel-qcow2-util-linux-46ed18361327845670316ecc6ab13afba7cceb43.tar.xz
kernel-qcow2-util-linux-46ed18361327845670316ecc6ab13afba7cceb43.zip
whereis: avoid printing uninitialized string
The patbuf[] needs to be filled before print out. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/whereis.c')
-rw-r--r--misc-utils/whereis.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index ba83b159b..5339abab2 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';