summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/gzip/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/gzip/util.c')
-rw-r--r--gnu/usr.bin/gzip/util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gnu/usr.bin/gzip/util.c b/gnu/usr.bin/gzip/util.c
index 710e6c238bb..4bb3639709c 100644
--- a/gnu/usr.bin/gzip/util.c
+++ b/gnu/usr.bin/gzip/util.c
@@ -5,7 +5,7 @@
*/
#ifdef RCSID
-static char rcsid[] = "$Id: util.c,v 1.2 2002/11/05 16:16:14 henning Exp $";
+static char rcsid[] = "$Id: util.c,v 1.3 2003/04/26 22:12:00 deraadt Exp $";
#endif
#include <ctype.h>
@@ -286,12 +286,15 @@ char *add_envopt(argcp, argvp, env)
char **nargv; /* runs through new argv array */
int oargc = *argcp; /* old argc */
int nargc = 0; /* number of arguments in env variable */
+ size_t len;
env = (char*)getenv(env);
if (env == NULL) return NULL;
- p = (char*)xmalloc(strlen(env)+1);
- env = strcpy(p, env); /* keep env variable intact */
+ len = strlen(env)+1;
+ p = (char*)xmalloc(len);
+ strlcpy(p, env, len); /* keep env variable intact */
+ env = p;
for (p = env; *p; nargc++ ) { /* move through env */
p += strspn(p, SEPARATOR); /* skip leading separators */