summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2009-06-07 16:04:17 +0200
committerDenys Vlasenko2009-06-07 16:04:17 +0200
commitdf5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3 (patch)
treee243fbd828e4d430a6be01baa920798de9ed74c4
parent8f24f9812df8dec34a991b2c572092639586f154 (diff)
downloadbusybox-df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3.zip
busybox-df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3.tar.gz
hush: fix a segfault in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e827660..6c20615 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6825,7 +6825,18 @@ static int FAST_FUNC builtin_export(char **argv)
{
unsigned opt_unexport;
- if (argv[1] == NULL) {
+#if ENABLE_HUSH_EXPORT_N
+ /* "!": do not abort on errors */
+ opt_unexport = getopt32(argv, "!n");
+ if (opt_unexport == (uint32_t)-1)
+ return EXIT_FAILURE;
+ argv += optind;
+#else
+ opt_unexport = 0;
+ argv++;
+#endif
+
+ if (argv[0] == NULL) {
char **e = environ;
if (e) {
while (*e) {
@@ -6851,18 +6862,6 @@ static int FAST_FUNC builtin_export(char **argv)
return EXIT_SUCCESS;
}
-#if ENABLE_HUSH_EXPORT_N
- /* "!": do not abort on errors */
- /* "+": stop at 1st non-option */
- opt_unexport = getopt32(argv, "!+n");
- if (opt_unexport == (unsigned)-1)
- return EXIT_FAILURE;
- argv += optind;
-#else
- opt_unexport = 0;
- argv++;
-#endif
-
helper_export_local(argv, (opt_unexport ? -1 : 1), 0);
return EXIT_SUCCESS;