]> diplodocus.org Git - nmh/commitdiff
Resized buffer, and moved it to the only block where it's used.
authorDavid Levine <levinedl@acm.org>
Wed, 31 Oct 2018 23:09:33 +0000 (19:09 -0400)
committerDavid Levine <levinedl@acm.org>
Wed, 31 Oct 2018 23:09:33 +0000 (19:09 -0400)
gcc 8 noticed that snprintf could have overrun it.

uip/whatnowsbr.c

index e1729df775e51c26d995b93bcc8131dd45a4860f..945afbab753df9e8f053ad12c51bd83abf6efcc7 100644 (file)
@@ -156,7 +156,6 @@ WhatNow (int argc, char **argv)
     char **argp, **arguments;
     struct stat st;
     char       cwd[PATH_MAX + 1];      /* current working directory */
-    char       file[PATH_MAX + 1];     /* file name buffer */
     char       shell[PATH_MAX + 1];    /* shell response buffer */
     FILE       *f;                     /* read pointer for bgnd proc */
     char       *l;                     /* set on -l to alist  command */
@@ -450,6 +449,8 @@ WhatNow (int argc, char **argv)
             */
 
            if ((f = popen_in_dir(cwd, buf, "r")) != NULL) {
+                char file[2 * PATH_MAX + 2]; /* file name buffer */
+
                while (fgets(shell, sizeof (shell), f) != NULL) {
                    char *ctype;