From ba84528d41d39adb0b26fdac0fafacc0614af7d4 Mon Sep 17 00:00:00 2001 From: Jacek Bukarewicz Date: Thu, 5 Sep 2013 04:58:06 -0500 Subject: env - there were 2 segfaults when run on my Ubuntu 12.04 machine: - one is because eglibc sets environ to NULL on clearenv(). I added check for environ being not NULL when iterating over environment variables - switched xexec to xexec_optargs because command argument is a pointer to optarg which is freed by xexec. --- toys/posix/env.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys/posix/env.c') diff --git a/toys/posix/env.c b/toys/posix/env.c index 8f7ccf1f..4e819f24 100644 --- a/toys/posix/env.c +++ b/toys/posix/env.c @@ -45,7 +45,7 @@ void env_main(void) if (!command) { char **ep; - for (ep = environ; *ep; ep++) xputs(*ep); - return; - } else xexec(command); + if (environ) for (ep = environ; *ep; ep++) xputs(*ep); + } else xexec_optargs(command - toys.optargs); + } -- cgit v1.2.3