From: Dmitry Stogov Date: Wed, 30 Sep 2009 13:04:28 +0000 (+0000) Subject: pcntl_exec() should inherit environment in case it's not provided as an argument X-Git-Tag: php-5.4.0alpha1~191^2~2563 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7b1e076472982a9d40be7f54fbe7eef22e046b2;p=php pcntl_exec() should inherit environment in case it's not provided as an argument --- diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index d85ee2863e..5b83522b84 100755 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -727,18 +727,21 @@ PHP_FUNCTION(pcntl_exec) if (return_val == HASH_KEY_IS_LONG) efree(key); } *(pair) = NULL; - } - - if (execve(path, argv, envp) == -1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno)); - } - - /* Cleanup */ - if (envp != NULL) { + + if (execve(path, argv, envp) == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno)); + } + + /* Cleanup */ for (pair = envp; *pair != NULL; pair++) efree(*pair); efree(envp); - } + } else { + if (execv(path, argv) == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno)); + } + } + efree(argv); RETURN_FALSE;