From 73dea7905cb5fea2540256bacdfde33fe0ad1a0b Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Wed, 22 Nov 2000 18:26:10 +0000 Subject: Only reference environ indirectly through a pointer --- newlib/libc/posix/execl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'newlib/libc/posix/execl.c') 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 +/* 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 @@ -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); } -- cgit v1.2.3