aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Bukarewicz <j.bukarewicz@samsung.com>2013-09-05 04:58:06 -0500
committerJacek Bukarewicz <j.bukarewicz@samsung.com>2013-09-05 04:58:06 -0500
commitba84528d41d39adb0b26fdac0fafacc0614af7d4 (patch)
tree503f390bea36b64465f0d0cfdb9b7ed6ccdb40ea
parent314dc6881f0439478f483d26726c52c1c3f536ff (diff)
downloadtoybox-ba84528d41d39adb0b26fdac0fafacc0614af7d4.tar.gz
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.
-rw-r--r--toys/posix/env.c6
1 files changed, 3 insertions, 3 deletions
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);
+
}