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.
This commit is contained in:
Andrey A. Chernov 2007-04-30 19:25:00 +00:00
parent eea319c4b7
commit ed4bcacfde

6
usr.bin/env/env.c vendored
View File

@ -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)