busybox/shell/hush_test/hush-vars
Sören Tempel fa52ac9781 ash: don't read past end of var in subvareval for bash substitutions
Without this patch, BusyBox handles bash pattern substitutions without
a terminating '/' character incorrectly.

Consider the following shell script:

	_bootstrapver=5.0.211-r0
	_referencesdir="/usr/${_bootstrapver/-*}/Sources"
	echo $_referencesdir

This should output `/usr/5.0.211/Sources`. However, without this patch
it instead outputs `/usr/5.0.211Sources`. This is due to the fact that
BusyBox expects the bash pattern substitutions to always be terminated
with a '/' (at least in this part of subvareval) and thus reads passed
the substitution itself and consumes the '/' character which is part of
the literal string. If there is no '/' after the substitution then
BusyBox might perform an out-of-bounds read under certain circumstances.

When replacing the bash pattern substitution with `${_bootstrapver/-*/}`,
or with this patch applied, ash outputs the correct value.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-03-01 08:47:43 +01:00
..
empty.right
empty.tests
glob_and_vars.right
glob_and_vars.tests
param_expand_alt2.right
param_expand_alt2.tests
param_expand_alt.right
param_expand_alt.tests
param_expand_assign.right
param_expand_assign.tests
param_expand_bash_substring.right
param_expand_bash_substring.tests
param_expand_default.right
param_expand_default.tests
param_expand_indicate_error.right
param_expand_indicate_error.tests
param_expand_len1.right
param_expand_len1.tests
param_expand_len.right
param_expand_len.tests
param_glob.right
param_glob.tests
param_subshell.right
param_subshell.tests
readonly0.right
readonly0.tests
readonly2.right
readonly2.tests
readonly3.right
readonly3.tests
star.right
star.tests
unset.right
unset.tests
var1.right
var1.tests
var2.right
var2.tests
var3.right
var3.tests
var4.right
var4.tests
var5.right
var5.tests
var6.right hush: fix bkslash+newline handling and number validation in ${NN} and ${#NN} 2021-06-19 15:45:45 +02:00
var6.tests ahell: update testsuite 2021-07-25 22:03:16 +02:00
var_10.right ash: parser: Only accept single-digit parameter expansion outside of braces 2020-02-17 10:15:35 +01:00
var_10.tests ash: parser: Only accept single-digit parameter expansion outside of braces 2020-02-17 10:15:35 +01:00
var_bash1.right
var_bash1.tests
var_bash1a.right
var_bash1a.tests
var_bash1b.right
var_bash1b.tests
var_bash2.right
var_bash2.tests
var_bash3.right
var_bash3.tests
var_bash4.right
var_bash4.tests
var_bash5.right
var_bash5.tests
var_bash6.right
var_bash6.tests
var_bash7.right hush: implement $'str' bashism 2021-07-26 15:32:46 +02:00
var_bash7.tests hush: implement $'str' bashism 2021-07-26 15:32:46 +02:00
var_bash_pattern_starting_with_slash.right
var_bash_pattern_starting_with_slash.tests
var_bash_repl_empty_pattern.right
var_bash_repl_empty_pattern.tests
var_bash_repl_empty_var.right hush: fix fallout from tweaking ${var:START:LEN} code 2020-12-23 12:38:03 +01:00
var_bash_repl_empty_var.tests hush: fix fallout from tweaking ${var:START:LEN} code 2020-12-23 12:38:03 +01:00
var_bash_repl_unterminated.right ash: don't read past end of var in subvareval for bash substitutions 2022-03-01 08:47:43 +01:00
var_bash_repl_unterminated.tests ash: don't read past end of var in subvareval for bash substitutions 2022-03-01 08:47:43 +01:00
var_expand_in_assign.right
var_expand_in_assign.tests
var_expand_in_redir.right
var_expand_in_redir.tests
var_expand_on_ifs.right
var_expand_on_ifs.tests
var_in_pipes.right
var_in_pipes.tests
var_leaks.right
var_leaks.tests
var_LINENO1.right
var_LINENO1.tests
var_LINENO2.right ash: fix LINENO in functions 2021-09-07 18:01:49 +02:00
var_LINENO2.tests ash: fix LINENO in functions 2021-09-07 18:01:49 +02:00
var_LINENO3.right ash: LINENO starts from 0 in -c SCRIPT mode 2021-09-07 18:16:45 +02:00
var_LINENO3.tests ash: LINENO starts from 0 in -c SCRIPT mode 2021-09-07 18:16:45 +02:00
var_nested1.right
var_nested1.tests
var_nested2.right
var_nested2.tests
var_posix1.right
var_posix1.tests
var_preserved.right
var_preserved.tests
var_serial.right
var_serial.tests
var_subst_in_for.right
var_subst_in_for.tests
var_unbackslash1.right
var_unbackslash1.tests
var_unbackslash.right
var_unbackslash.tests
var_wordsplit_ifs1.right
var_wordsplit_ifs1.tests
var_wordsplit_ifs2.right
var_wordsplit_ifs2.tests
var_wordsplit_ifs3.right
var_wordsplit_ifs3.tests
var_wordsplit_ifs4.right
var_wordsplit_ifs4.tests
var_wordsplit_ifs5.right
var_wordsplit_ifs5.tests
var-do-not-collapse-arithmetic-expansion-at-parse-time.right
var-do-not-collapse-arithmetic-expansion-at-parse-time.tests
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests
var-pattern-replacement-in-parameter-expansion-1.right
var-pattern-replacement-in-parameter-expansion-1.tests
var-pattern-replacement-in-parameter-expansion-2.right
var-pattern-replacement-in-parameter-expansion-2.tests
var-pattern-replacement-in-parameter-expansion-3.right
var-pattern-replacement-in-parameter-expansion-3.tests
var-pattern-replacement-in-parameter-expansion-4.right
var-pattern-replacement-in-parameter-expansion-4.tests
var-pattern-replacement-in-parameter-expansion-5.right
var-pattern-replacement-in-parameter-expansion-5.tests
var-runtime-quote-detection.right
var-runtime-quote-detection.tests
var-utf8-length.right
var-utf8-length.tests