mirror of
https://github.com/sheumann/hush.git
synced 2024-11-18 17:10:36 +00:00
printenv: fix environ == NULL segfault
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
6b6af53426
commit
86cf0364bd
@ -19,9 +19,14 @@ int printenv_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
/* no variables specified, show whole env */
|
||||
if (!argv[1]) {
|
||||
int e = 0;
|
||||
while (environ[e])
|
||||
puts(environ[e++]);
|
||||
char **e = environ;
|
||||
|
||||
/* environ can be NULL! (for example, after clearenv())
|
||||
* Check for that:
|
||||
*/
|
||||
if (e)
|
||||
while (*e)
|
||||
puts(*e++);
|
||||
} else {
|
||||
/* search for specified variables and print them out if found */
|
||||
char *arg, *env;
|
||||
|
@ -45,7 +45,7 @@
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
/* test_main() is called from shells, and we need to be extra careful here.
|
||||
* This is true regardless of PREFER_APPLETS and STANDALONE_SHELL
|
||||
* This is true regardless of PREFER_APPLETS and SH_STANDALONE
|
||||
* state. */
|
||||
|
||||
/* test(1) accepts the following grammar:
|
||||
|
Loading…
Reference in New Issue
Block a user