diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-06 12:07:11 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-06 12:08:43 +0200 |
commit | 457825f77a7c7286647ee888a1000a6bb12ca8fc (patch) | |
tree | f4deac5510cbae6299b964f48d4c8cad8bde3ce4 /shell/hush.c | |
parent | a1b0d3856d9a0419cb74bf4c87525265871b5868 (diff) | |
download | busybox-w32-457825f77a7c7286647ee888a1000a6bb12ca8fc.tar.gz busybox-w32-457825f77a7c7286647ee888a1000a6bb12ca8fc.tar.bz2 busybox-w32-457825f77a7c7286647ee888a1000a6bb12ca8fc.zip |
shells: do not allow bare "read" in non-bash compat configs
On Sat, Feb 9, 2019 Cristian Ionescu-Idbohrn wrote:
> In my case (at work), I have to watch and prevent people from doing
> unportable things. For me, that's a burden.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 144ad3edd..77921e11c 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4251,7 +4251,7 @@ static int done_word(struct parse_context *ctx) | |||
4251 | || endofname(command->argv[0])[0] != '\0' | 4251 | || endofname(command->argv[0])[0] != '\0' |
4252 | ) { | 4252 | ) { |
4253 | /* bash says just "not a valid identifier" */ | 4253 | /* bash says just "not a valid identifier" */ |
4254 | syntax_error("not a valid identifier in for"); | 4254 | syntax_error("bad variable name in for"); |
4255 | return 1; | 4255 | return 1; |
4256 | } | 4256 | } |
4257 | /* Force FOR to have just one word (variable name) */ | 4257 | /* Force FOR to have just one word (variable name) */ |
@@ -10799,10 +10799,17 @@ static int FAST_FUNC builtin_read(char **argv) | |||
10799 | */ | 10799 | */ |
10800 | params.read_flags = getopt32(argv, | 10800 | params.read_flags = getopt32(argv, |
10801 | # if BASH_READ_D | 10801 | # if BASH_READ_D |
10802 | "!srn:p:t:u:d:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u, ¶ms.opt_d | 10802 | IF_NOT_HUSH_BASH_COMPAT("^") |
10803 | "!srn:p:t:u:d:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/), | ||
10804 | ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u, ¶ms.opt_d | ||
10803 | # else | 10805 | # else |
10804 | "!srn:p:t:u:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u | 10806 | IF_NOT_HUSH_BASH_COMPAT("^") |
10807 | "!srn:p:t:u:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/), | ||
10808 | ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u | ||
10805 | # endif | 10809 | # endif |
10810 | //TODO: print "read: need variable name" | ||
10811 | //for the case of !BASH "read" with no args (now it fails silently) | ||
10812 | //(or maybe extend getopt32() to emit a message if "-1" fails) | ||
10806 | ); | 10813 | ); |
10807 | if ((uint32_t)params.read_flags == (uint32_t)-1) | 10814 | if ((uint32_t)params.read_flags == (uint32_t)-1) |
10808 | return EXIT_FAILURE; | 10815 | return EXIT_FAILURE; |