From de97550b4e88a1751b77db7f1825724e46bbda4e Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 30 Apr 2007 19:25:00 +0000 Subject: env calls setenv("name=value", "value", 1); which violates POSIX: "The setenv( ) function shall fail if: [EINVAL] The name argument is a null pointer, points to an empty string, or points to a string containing an '=' character." The fix (like all others in this subject) is backward-compatible. --- usr.bin/env/env.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.bin/env/env.c') diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index 815976f..b5866ef 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -64,7 +64,7 @@ static void usage(void); int main(int argc, char **argv) { - char *altpath, **ep, *p, **parg; + char *altpath, **ep, **parg; char *cleanenv[1]; int ch, want_clear; @@ -102,10 +102,10 @@ main(int argc, char **argv) if (env_verbosity) fprintf(stderr, "#env clearing environ\n"); } - for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) { + for (argv += optind; *argv && strchr(*argv, '=') != NULL; ++argv) { if (env_verbosity) fprintf(stderr, "#env setenv:\t%s\n", *argv); - (void)setenv(*argv, ++p, 1); + (void)putenv(strdup(*argv)); } if (*argv) { if (altpath) -- cgit v1.1