summaryrefslogtreecommitdiffstats
path: root/newlib/libc/posix
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/posix')
-rw-r--r--newlib/libc/posix/execl.c7
-rw-r--r--newlib/libc/posix/execv.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/newlib/libc/posix/execl.c b/newlib/libc/posix/execl.c
index 075df8eba..098005666 100644
--- a/newlib/libc/posix/execl.c
+++ b/newlib/libc/posix/execl.c
@@ -6,6 +6,11 @@
#include <_ansi.h>
#include <unistd.h>
+/* Only deal with a pointer to environ, to work around subtle bugs with shared
+ libraries and/or small data systems where the user declares his own
+ 'environ'. */
+static char ***p_environ = &environ;
+
#ifdef _HAVE_STDC
#include <stdarg.h>
@@ -38,5 +43,5 @@ execl (path, arg0, va_alist)
while (argv[i++] != NULL);
va_end (args);
- return _execve (path, (char * _CONST *) argv, environ);
+ return _execve (path, (char * _CONST *) argv, *p_environ);
}
diff --git a/newlib/libc/posix/execv.c b/newlib/libc/posix/execv.c
index 42a78cb52..5effb9c57 100644
--- a/newlib/libc/posix/execv.c
+++ b/newlib/libc/posix/execv.c
@@ -6,10 +6,15 @@
#include <_ansi.h>
#include <unistd.h>
+/* Only deal with a pointer to environ, to work around subtle bugs with shared
+ libraries and/or small data systems where the user declares his own
+ 'environ'. */
+static char ***p_environ = &environ;
+
int
_DEFUN (execv, (path, argv),
const char *path _AND
char * const argv[])
{
- return _execve (path, (char * _CONST *) argv, environ);
+ return _execve (path, (char * _CONST *) argv, *p_environ);
}