svn commit: r199862 - head/lib/libc/gen

Ed Schouten ed at FreeBSD.org
Fri Nov 27 13:05:14 UTC 2009


Author: ed
Date: Fri Nov 27 13:05:14 2009
New Revision: 199862
URL: http://svn.freebsd.org/changeset/base/199862

Log:
  Properly use the envp argument in execvPe().
  
  execvPe() is called by _execvpe(), which we added to implement
  posix_spawnp(). We just took execvP() and added the envp argument.
  Unfortunately we forgot to change the implementation to use envp over
  environ.
  
  This fixes the following piece of code:
  
  | char * const arg[2] = { "env", NULL };
  | char * const env[2] = { "FOO=BAR", NULL };
  | posix_spawnp(NULL, "/usr/bin/env", NULL, NULL, arg, env);
  
  MFC after:	2 weeks

Modified:
  head/lib/libc/gen/exec.c

Modified: head/lib/libc/gen/exec.c
==============================================================================
--- head/lib/libc/gen/exec.c	Fri Nov 27 10:55:28 2009	(r199861)
+++ head/lib/libc/gen/exec.c	Fri Nov 27 13:05:14 2009	(r199862)
@@ -209,7 +209,7 @@ execvPe(name, path, argv, envp)
 		bcopy(name, buf + lp + 1, ln);
 		buf[lp + ln + 1] = '\0';
 
-retry:		(void)_execve(bp, argv, environ);
+retry:		(void)_execve(bp, argv, envp);
 		switch (errno) {
 		case E2BIG:
 			goto done;
@@ -228,7 +228,7 @@ retry:		(void)_execve(bp, argv, environ)
 			memp[0] = "sh";
 			memp[1] = bp;
 			bcopy(argv + 1, memp + 2, cnt * sizeof(char *));
-			(void)_execve(_PATH_BSHELL, memp, environ);
+			(void)_execve(_PATH_BSHELL, memp, envp);
 			goto done;
 		case ENOMEM:
 			goto done;


More information about the svn-src-head mailing list