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 hush: fix some fallout from prev commits, add testsuite 2008-06-10 18:06:24 +00:00
empty.tests cosmetics in hush testsuites 2008-06-18 17:53:57 +00:00
glob_and_vars.right hush: fix hush-bugs/glob_and_vars.tests testcase: 2008-06-16 12:47:11 +00:00
glob_and_vars.tests hush: fix hush-bugs/glob_and_vars.tests testcase: 2008-06-16 12:47:11 +00:00
param_expand_alt.right shell: remove ${#+} tests, it is not a valid construct 2017-07-26 00:30:02 +02:00
param_expand_alt.tests shell: remove ${#+} tests, it is not a valid construct 2017-07-26 00:30:02 +02:00
param_expand_alt2.right ash: parser: Allow newlines within parameter substitution 2018-04-11 12:39:18 +02:00
param_expand_alt2.tests ash: parser: Allow newlines within parameter substitution 2018-04-11 12:39:18 +02:00
param_expand_assign.right hush: deal with some easier TODOs 2009-04-09 19:16:15 +00:00
param_expand_assign.tests ash: add a few tests from hush-vars/* 2017-07-25 14:55:05 +02:00
param_expand_bash_substring.right shell: echo ${?:0} was fixed sometime ago, enable it in tests 2018-01-13 19:28:19 +01:00
param_expand_bash_substring.tests shell: echo ${?:0} was fixed sometime ago, enable it in tests 2018-01-13 19:28:19 +01:00
param_expand_default.right hush: remove test for "echo ${-}" errorring out - now it works 2019-05-19 16:35:56 +02:00
param_expand_default.tests hush: remove test for "echo ${-}" errorring out - now it works 2019-05-19 16:35:56 +02:00
param_expand_indicate_error.right hush: treat ${#?} as "length of $?" 2017-07-25 15:18:57 +02:00
param_expand_indicate_error.tests hush: treat ${#?} as "length of $?" 2017-07-25 15:18:57 +02:00
param_expand_len.right ash: [PARSER] Fix parsing of ${##1} 2016-10-26 15:56:53 +02:00
param_expand_len.tests ash: [PARSER] Fix parsing of ${##1} 2016-10-26 15:56:53 +02:00
param_expand_len1.right hush: fix ${##}, ${#?}, ${#!} handling 2017-07-26 00:07:27 +02:00
param_expand_len1.tests hush: fix ${##}, ${#?}, ${#!} handling 2017-07-26 00:07:27 +02:00
param_glob.right fix globbing in unquoted $* and $@ 2008-06-18 17:49:58 +00:00
param_glob.tests hush: fix exec builtin in a better way (+ "glob in exec" bug fixed) 2009-10-19 23:09:06 +02:00
param_subshell.right hush: fix passing of $n on NOMMU 2009-04-05 02:10:39 +00:00
param_subshell.tests hush: tighten up "for" variable name check. 2009-04-10 12:03:20 +00:00
readonly2.right hush: fix readonly2.tests failure 2017-07-18 15:58:02 +02:00
readonly2.tests hush: fix readonly2.tests failure 2017-07-18 15:58:02 +02:00
readonly3.right hush: fix for readonly vars in "ro=A ro=B cmd" case 2018-04-04 21:14:28 +02:00
readonly3.tests hush: fix for readonly vars in "ro=A ro=B cmd" case 2018-04-04 21:14:28 +02:00
readonly0.right hush: another testcase for "READONLY_VAR=VAL BLTIN ..." 2017-07-18 03:23:07 +02:00
readonly0.tests hush: another testcase for "READONLY_VAR=VAL BLTIN ..." 2017-07-18 03:23:07 +02:00
star.right
star.tests
unset.right ash: [VAR] Move unsetvar functionality into setvareq 2017-07-25 16:29:36 +02:00
unset.tests hush: fix false positive in unset.tests 2017-08-29 14:35:58 +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_bash_pattern_starting_with_slash.right ash,hush: properly handle ${v//pattern/repl} if pattern starts with / 2018-08-04 22:25:28 +02:00
var_bash_pattern_starting_with_slash.tests ash,hush: properly handle ${v//pattern/repl} if pattern starts with / 2018-08-04 22:25:28 +02:00
var_bash_repl_empty_pattern.right hush: fix two corner cases in ${v/pattern/repl}. Closes 10686 2018-01-25 14:07:40 +01:00
var_bash_repl_empty_pattern.tests hush: fix two corner cases in ${v/pattern/repl}. Closes 10686 2018-01-25 14:07:40 +01:00
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_bash1.right hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash1.tests hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash1a.right hush: implement negative start in the ${v: -n[:m]} idiom 2017-07-06 19:48:20 +02:00
var_bash1a.tests typo fix 2017-07-06 19:50:42 +02:00
var_bash1b.right hush: support ${VAR:N:-M} 2017-07-17 16:46:57 +02:00
var_bash1b.tests hush: support ${VAR:N:-M} 2017-07-17 16:46:57 +02:00
var_bash2.right hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash2.tests hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash3.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash3.tests hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash4.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash4.tests hush: fix globbing+backslashes in unquoted $var expansion 2010-09-06 10:26:37 +02:00
var_bash5.right hush: fix var_bash5.tests failure 2010-09-10 10:17:53 +02:00
var_bash5.tests hush: fix var_bash5.tests failure 2010-09-10 10:17:53 +02:00
var_bash6.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash6.tests ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
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_expand_in_assign.right
var_expand_in_assign.tests
var_expand_in_redir.right hush: fix $ expansion in redirections, add testcase for that 2007-11-23 21:08:38 +00:00
var_expand_in_redir.tests hush: fix $ expansion in redirections, add testcase for that 2007-11-23 21:08:38 +00:00
var_expand_on_ifs.right hush: partially fix wrong expansion on $IFS (bug 4027). 2011-08-01 14:06:20 +02:00
var_expand_on_ifs.tests hush: partially fix wrong expansion on $IFS (bug 4027). 2011-08-01 14:06:20 +02:00
var_in_pipes.right hush: fix bug with local environment vars in pipes; simplify parse_stream() 2009-04-03 03:19:15 +00:00
var_in_pipes.tests hush: fix bug with local environment vars in pipes; simplify parse_stream() 2009-04-03 03:19:15 +00:00
var_leaks.right hush: fix environment and memory leaks, add tests for them 2008-10-09 16:29:44 +00:00
var_leaks.tests hush: fix environment and memory leaks, add tests for them 2008-10-09 16:29:44 +00:00
var_LINENO1.right hush: implement $LINENO bashism 2018-01-19 15:52:36 +01:00
var_LINENO1.tests shells: fix var_LINENO1.tests false positive, add it to ash tests too 2018-03-31 20:31:13 +02:00
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 hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= f 2018-04-05 00:51:55 +02:00
var_nested1.tests hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= f 2018-04-05 00:51:55 +02:00
var_nested2.right hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= f 2018-04-05 00:51:55 +02:00
var_nested2.tests hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= f 2018-04-05 00:51:55 +02:00
var_posix1.right hush: fix more obscure ${var%...} cases 2010-05-22 00:26:06 +02:00
var_posix1.tests hush: fix more obscure ${var%...} cases 2010-05-22 00:26:06 +02:00
var_preserved.right hush: fix NOMMU bug (analogous to preceding commit for MMU) 2008-10-13 12:36:05 +00:00
var_preserved.tests hush: fix NOMMU bug (analogous to preceding commit for MMU) 2008-10-13 12:36:05 +00:00
var_serial.right hush: fix multimple dependent variable expansion cases 2010-07-16 13:52:32 +02:00
var_serial.tests hush: fix multimple dependent variable expansion cases 2010-07-16 13:52:32 +02:00
var_subst_in_for.right
var_subst_in_for.tests cosmetics in hush testsuites 2008-06-18 17:53:57 +00:00
var_unbackslash.right hush: make parse_dollar flag quited status regardless of glob escaping status 2010-09-09 14:04:57 +02:00
var_unbackslash.tests hush: make parse_dollar flag quited status regardless of glob escaping status 2010-09-09 14:04:57 +02:00
var_unbackslash1.right ash: fix arithmetic closing )) split by backslash-newline 2016-09-29 17:58:58 +02:00
var_unbackslash1.tests shell testsuite: add trailing newline to var_unbackslash1.tests 2016-09-29 20:02:53 +02:00
var_wordsplit_ifs1.right ash: expand: Fixed "$@" expansion when EXP_FULL is false 2016-10-02 02:46:56 +02:00
var_wordsplit_ifs1.tests ash: expand: Fixed "$@" expansion when EXP_FULL is false 2016-10-02 02:46:56 +02:00
var_wordsplit_ifs2.right ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs2.tests ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs3.right ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs3.tests ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs4.right hush: IFS fixes 2018-04-11 16:02:58 +02:00
var_wordsplit_ifs4.tests hush: IFS fixes 2018-04-11 16:02:58 +02:00
var_wordsplit_ifs5.right ash: expand: Fix ghost fields with unquoted $@/$* 2018-08-05 14:29:58 +02:00
var_wordsplit_ifs5.tests ash: expand: Fix ghost fields with unquoted $@/$* 2018-08-05 14:29:58 +02:00
var-do-not-collapse-arithmetic-expansion-at-parse-time.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-do-not-collapse-arithmetic-expansion-at-parse-time.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-1.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-1.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-2.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-2.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-3.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-3.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-4.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-4.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-5.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-pattern-replacement-in-parameter-expansion-5.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-runtime-quote-detection.right hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-runtime-quote-detection.tests hush: add recent ash tests to hush testsuite too (they all pass for hush) 2015-05-18 10:23:16 +02:00
var-utf8-length.right hush: "adopt" ash var-utf8-length.tests 2017-07-06 19:29:23 +02:00
var-utf8-length.tests hush: "adopt" ash var-utf8-length.tests 2017-07-06 19:29:23 +02:00
var1.right hush: add support for special vars in braces 2009-06-01 14:16:43 -04:00
var1.tests hush: add support for special vars in braces 2009-06-01 14:16:43 -04:00
var2.right hush: support $_NUMBERS variable names 2008-07-31 10:34:48 +00:00
var2.tests hush: support $_NUMBERS variable names 2008-07-31 10:34:48 +00:00
var3.right hush: fix var3.tests 2016-10-02 21:12:02 +02:00
var3.tests hush: fix var3.tests 2016-10-02 21:12:02 +02:00
var4.right hush: add var4.tests, var5.tests 2016-10-02 21:13:13 +02:00
var4.tests hush: add var4.tests, var5.tests 2016-10-02 21:13:13 +02:00
var5.right hush: add var4.tests, var5.tests 2016-10-02 21:13:13 +02:00
var5.tests hush: add var4.tests, var5.tests 2016-10-02 21:13:13 +02:00
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