From: Guus Sliepen Date: Fri, 1 Oct 2004 18:24:41 +0000 (+0000) Subject: strndupa() is too arcane for some environments. X-Git-Tag: import-tinc-1.1~774 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=6411e0d8bda8abc2cef87ca852255502f9bb03d0;p=meshlink strndupa() is too arcane for some environments. --- diff --git a/src/process.c b/src/process.c index 7500259f..9194bedf 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