OSDN Git Service

* exec.cc (execvp): Call find_exec with FE_NNF flag to enforce
authorcorinna <corinna>
Tue, 22 Dec 2009 00:16:27 +0000 (00:16 +0000)
committercorinna <corinna>
Tue, 22 Dec 2009 00:16:27 +0000 (00:16 +0000)
a NULL return when executable isn't found in $PATH.  Convert NULL
to "".
(execvpe): Ditto.
* spawn.cc (spawn_guts): Return with EFAULT if prog_arg is NULL.
Return with ENOENT if prog_arg is empty string.  Add a comment.

winsup/cygwin/ChangeLog
winsup/cygwin/exec.cc
winsup/cygwin/spawn.cc

index 50b4739..77bc861 100644 (file)
@@ -1,3 +1,12 @@
+2009-12-21  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exec.cc (execvp): Call find_exec with FE_NNF flag to enforce
+       a NULL return when executable isn't found in $PATH.  Convert NULL
+       to "".
+       (execvpe): Ditto.
+       * spawn.cc (spawn_guts): Return with EFAULT if prog_arg is NULL.
+       Return with ENOENT if prog_arg is empty string.  Add a comment.
+
 2009-12-21  Thomas Wolff  <towo@towo.net>
 
        * fhandler_console.cc (get_nonascii_key): Generate ESC prefix 
index 131439f..b1fd527 100644 (file)
@@ -86,14 +86,14 @@ extern "C" int
 execvp (const char *path, char * const *argv)
 {
   path_conv buf;
-  return  execv (find_exec (path, buf), argv);
+  return execv (find_exec (path, buf, "PATH=", FE_NNF) ?: "", argv);
 }
 
 extern "C" int
 execvpe (const char *path, char * const *argv, char *const *envp)
 {
   path_conv buf;
-  return  execve (find_exec (path, buf), argv, envp);
+  return execve (find_exec (path, buf, "PATH=", FE_NNF) ?: "", argv, envp);
 }
 
 extern "C" int
index 9284996..fdbab76 100644 (file)
@@ -281,12 +281,19 @@ spawn_guts (const char *prog_arg, const char *const *argv,
   if (prog_arg == NULL)
     {
       syscall_printf ("prog_arg is NULL");
-      set_errno (EINVAL);
+      set_errno (EFAULT);      /* As on Linux. */
+      return -1;
+    }
+  if (!prog_arg[0])
+    {
+      syscall_printf ("prog_arg is empty");
+      set_errno (ENOENT);      /* Per POSIX */
       return -1;
     }
 
   syscall_printf ("spawn_guts (%d, %.9500s)", mode, prog_arg);
 
+  /* FIXME: This is no error condition on Linux. */
   if (argv == NULL)
     {
       syscall_printf ("argv is NULL");