klibc-bot for Martijn Dekker
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: expand: 'nolog' and 'debug' options cause "$-" to wreak havoc
Commit-ID: 8d7c846f252b7eabd7cb7d02e7b53fb5a835402e Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=8d7c846f252b7eabd7cb7d02e7b53fb5a835402e Author: Martijn Dekker <martijn at inlv.org> AuthorDate: Tue, 6 Mar 2018 17:40:37 +0000 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: expand: 'nolog' and 'debug' options cause "$-" to wreak havoc [ dash commit 81a501b7fbcff8da004251a85a8f948263254aa5 ] Op 29-03-17 om 20:02 schreef Martijn Dekker:> Bug: if either the 'nolog' or the 'debug' option is set, trying to > expand "$-" silently aborts parsing of an entire argument. > > $ dash -o nolog -c 'set -fuC; echo "|$- are the options|"; \ > set +o nolog; echo "|$- are the options|"' > | > |uCf are the options| > $ dash -o debug -c 'set -fuC; echo "|$- are the options|"; \ > set +o debug; echo "|$- are the options|"' > | > |uCf are the options|This turned out to be easy to fix. The routine producing the "$-" expansion failed to skip options for which there is no option letter, but only a long-form name. In dash, 'nolog' and 'debug' are currently the only two such options. Patch below. - Martijn Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/expand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/dash/expand.c b/usr/dash/expand.c index 153f6b7a..e86bd29d 100644 --- a/usr/dash/expand.c +++ b/usr/dash/expand.c @@ -927,7 +927,7 @@ numvar: case '-': p = makestrspace(NOPTS, expdest); for (i = NOPTS - 1; i >= 0; i--) { - if (optlist[i]) { + if (optlist[i] && optletters[i]) { USTPUTC(optletters[i], p); len++; }