From 6411e0d8bda8abc2cef87ca852255502f9bb03d0 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 1 Oct 2004 18:24:41 +0000 Subject: [PATCH] strndupa() is too arcane for some environments. --- src/process.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/process.c b/src/process.c index 7500259..9194bed 100644 --- a/src/process.c +++ b/src/process.c @@ -362,7 +362,7 @@ bool execute_script(const char *name, char **envp) #ifdef HAVE_SYSTEM int status, len; struct stat s; - char *scriptname; + char *scriptname, *p; int i; cp(); @@ -400,8 +400,12 @@ bool execute_script(const char *name, char **envp) for(i = 0; envp[i]; i++) { char *e = strchr(envp[i], '='); - if(e) - putenv(strndupa(envp[i], e - envp[i])); + if(e) { + p = alloca(e - envp[i] + 1); + strncpy(p, envp[i], e - envp[i]); + p[e - envp[i]] = '\0'; + putenv(p); + } } #ifdef WEXITSTATUS -- 2.25.1