]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
whereis: avoid printing uninitialized string
authorSami Kerola <kerolasa@iki.fi>
Sun, 13 Jul 2014 17:13:38 +0000 (18:13 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 13 Jul 2014 17:35:38 +0000 (18:35 +0100)
The patbuf[] needs to be filled before print out.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/whereis.c

index ba83b159bdbd0a7b6e5dab9b710c5c46f6e1ea8a..5339abab271f029ce3b09668f708f91f16e893e1 100644 (file)
@@ -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';