Audit printenv(1)
1) argc style 2) safeguard argv-loop as already seen in echo(1) with argc-decrement.
This commit is contained in:
parent
6f715d8c6d
commit
0226c05105
2
README
2
README
|
@ -51,7 +51,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
|
|||
= nl no -d, -f, -h, -l, -p
|
||||
=* nohup yes none
|
||||
#* paste yes none
|
||||
=* printenv non-posix none
|
||||
=*| printenv non-posix none
|
||||
#* printf yes none
|
||||
=* pwd yes none
|
||||
= readlink non-posix none
|
||||
|
|
2
echo.c
2
echo.c
|
@ -23,7 +23,7 @@ main(int argc, char *argv[])
|
|||
} ARGEND;
|
||||
|
||||
for (; argc > 0; argc--, argv++)
|
||||
putword(argv[0]);
|
||||
putword(*argv);
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ extern char **environ;
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s [variable...]\n", argv0);
|
||||
eprintf("usage: %s [var ...]\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -23,16 +23,17 @@ main(int argc, char *argv[])
|
|||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc == 0) {
|
||||
if (!argc) {
|
||||
while (*environ)
|
||||
printf("%s\n", *environ++);
|
||||
} else {
|
||||
while (*argv) {
|
||||
if ((var = getenv(*argv++)))
|
||||
for (; argc > 0; argc--, argv++) {
|
||||
if ((var = getenv(*argv)))
|
||||
printf("%s\n", var);
|
||||
else
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user