[project @ 2005-07-22 10:18:51 by simonmar]
authorsimonmar <unknown>
Fri, 22 Jul 2005 10:18:51 +0000 (10:18 +0000)
committersimonmar <unknown>
Fri, 22 Jul 2005 10:18:51 +0000 (10:18 +0000)
check the return value of chdir()

  [ 1242598 ] runProcess uses cwd for bad working directory argument

cbits/runProcess.c

index d117e36..dd33b66 100644 (file)
@@ -47,7 +47,9 @@ runProcess (char *const args[], char *workingDirectory, char **environment,
        pPrPr_disableITimers();
        
        if (workingDirectory) {
-           chdir (workingDirectory);
+           if (chdir (workingDirectory) < 0) {
+               return -1;
+           }
        }
        
        /* Set the SIGINT/SIGQUIT signal handlers in the child, if requested 
@@ -107,7 +109,9 @@ runInteractiveProcess (char *const args[],
        pPrPr_disableITimers();
        
        if (workingDirectory) {
-           chdir (workingDirectory);
+           if (chdir (workingDirectory) < 0) {
+               return -1;
+           }
        }
        
        dup2 (fdStdInput[0], STDIN_FILENO);