diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-07 16:04:17 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-07 16:04:17 +0200 |
| commit | df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3 (patch) | |
| tree | e243fbd828e4d430a6be01baa920798de9ed74c4 /shell | |
| parent | 8f24f9812df8dec34a991b2c572092639586f154 (diff) | |
| download | busybox-w32-df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3.tar.gz busybox-w32-df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3.tar.bz2 busybox-w32-df5131cf3dd2c3d4e53c64b8b73f6cd18b46f6d3.zip | |
hush: fix a segfault in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/hush.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/shell/hush.c b/shell/hush.c index e82766093..6c20615fa 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -6825,7 +6825,18 @@ static int FAST_FUNC builtin_export(char **argv) | |||
| 6825 | { | 6825 | { |
| 6826 | unsigned opt_unexport; | 6826 | unsigned opt_unexport; |
| 6827 | 6827 | ||
| 6828 | if (argv[1] == NULL) { | 6828 | #if ENABLE_HUSH_EXPORT_N |
| 6829 | /* "!": do not abort on errors */ | ||
| 6830 | opt_unexport = getopt32(argv, "!n"); | ||
| 6831 | if (opt_unexport == (uint32_t)-1) | ||
| 6832 | return EXIT_FAILURE; | ||
| 6833 | argv += optind; | ||
| 6834 | #else | ||
| 6835 | opt_unexport = 0; | ||
| 6836 | argv++; | ||
| 6837 | #endif | ||
| 6838 | |||
| 6839 | if (argv[0] == NULL) { | ||
| 6829 | char **e = environ; | 6840 | char **e = environ; |
| 6830 | if (e) { | 6841 | if (e) { |
| 6831 | while (*e) { | 6842 | while (*e) { |
| @@ -6851,18 +6862,6 @@ static int FAST_FUNC builtin_export(char **argv) | |||
| 6851 | return EXIT_SUCCESS; | 6862 | return EXIT_SUCCESS; |
| 6852 | } | 6863 | } |
| 6853 | 6864 | ||
| 6854 | #if ENABLE_HUSH_EXPORT_N | ||
| 6855 | /* "!": do not abort on errors */ | ||
| 6856 | /* "+": stop at 1st non-option */ | ||
| 6857 | opt_unexport = getopt32(argv, "!+n"); | ||
| 6858 | if (opt_unexport == (unsigned)-1) | ||
| 6859 | return EXIT_FAILURE; | ||
| 6860 | argv += optind; | ||
| 6861 | #else | ||
| 6862 | opt_unexport = 0; | ||
| 6863 | argv++; | ||
| 6864 | #endif | ||
| 6865 | |||
| 6866 | helper_export_local(argv, (opt_unexport ? -1 : 1), 0); | 6865 | helper_export_local(argv, (opt_unexport ? -1 : 1), 0); |
| 6867 | 6866 | ||
| 6868 | return EXIT_SUCCESS; | 6867 | return EXIT_SUCCESS; |
