summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-06 12:07:11 +0200
committerDenys Vlasenko2021-06-06 12:08:43 +0200
commit457825f77a7c7286647ee888a1000a6bb12ca8fc (patch)
treef4deac5510cbae6299b964f48d4c8cad8bde3ce4 /shell/hush.c
parenta1b0d3856d9a0419cb74bf4c87525265871b5868 (diff)
downloadbusybox-457825f77a7c7286647ee888a1000a6bb12ca8fc.zip
busybox-457825f77a7c7286647ee888a1000a6bb12ca8fc.tar.gz
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.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 144ad3e..77921e1 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4251,7 +4251,7 @@ static int done_word(struct parse_context *ctx)
|| endofname(command->argv[0])[0] != '\0'
) {
/* bash says just "not a valid identifier" */
- syntax_error("not a valid identifier in for");
+ syntax_error("bad variable name in for");
return 1;
}
/* Force FOR to have just one word (variable name) */
@@ -10799,10 +10799,17 @@ static int FAST_FUNC builtin_read(char **argv)
*/
params.read_flags = getopt32(argv,
# if BASH_READ_D
- "!srn:p:t:u:d:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u, &params.opt_d
+ IF_NOT_HUSH_BASH_COMPAT("^")
+ "!srn:p:t:u:d:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/),
+ &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u, &params.opt_d
# else
- "!srn:p:t:u:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u
+ IF_NOT_HUSH_BASH_COMPAT("^")
+ "!srn:p:t:u:" IF_NOT_HUSH_BASH_COMPAT("\0" "-1"/*min 1 arg*/),
+ &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u
# endif
+//TODO: print "read: need variable name"
+//for the case of !BASH "read" with no args (now it fails silently)
+//(or maybe extend getopt32() to emit a message if "-1" fails)
);
if ((uint32_t)params.read_flags == (uint32_t)-1)
return EXIT_FAILURE;