diff options
author | ache <ache@FreeBSD.org> | 2007-04-30 19:25:00 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2007-04-30 19:25:00 +0000 |
commit | de97550b4e88a1751b77db7f1825724e46bbda4e (patch) | |
tree | 0c4abbfb44930be04a6cba6d2c55ddce6c9a6c78 /usr.bin | |
parent | b4aa820f7040499dcde01be962528453dbd12e1c (diff) | |
download | FreeBSD-src-de97550b4e88a1751b77db7f1825724e46bbda4e.zip FreeBSD-src-de97550b4e88a1751b77db7f1825724e46bbda4e.tar.gz |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/env/env.c | 6 |
1 files changed, 3 insertions, 3 deletions
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) |