]> granicus.if.org Git - sudo/commitdiff
made command (and therefor cmnd dynamically allocated)
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 Aug 1994 20:12:09 +0000 (20:12 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 Aug 1994 20:12:09 +0000 (20:12 +0000)
find_path.c

index 017ef2a42f3e77abd5c73d977da5170320c03544..80836e5b33b75c211422efdaf9d236493973a238 100644 (file)
@@ -97,7 +97,7 @@ char *find_path(file)
     char *path = NULL;         /* contents of PATH env var */
     char *oldpath;             /* so we can free path later */
     char *result = NULL;       /* result of path/file lookup */
-    static char command[MAXPATHLEN+1]; /* resolved pathname */
+    char *command;             /* resolved pathname */
     int checkdot = 0;          /* check current dir? */
 
     if (strlen(file) > MAXPATHLEN) {
@@ -105,6 +105,16 @@ char *find_path(file)
        exit(1);
     }
 
+    /*
+     * allocate memory for command
+     */
+    command = (char *) malloc(MAXPATHLEN + 1);
+    if (command == NULL) {
+       perror("malloc");
+       (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+       exit(1);
+    }
+
     /*
      * do we need to search the path?
      */