diff options
author | Martijn Dekker <martijn@inlv.org> | 2018-03-06 17:40:37 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 8d7c846f252b7eabd7cb7d02e7b53fb5a835402e (patch) | |
tree | 663593dd0f7b9f87a5875164c63d3136bb106eca | |
parent | a2020fbd897e3c3d41c75294f4e43a0e07487822 (diff) | |
download | klibc-8d7c846f252b7eabd7cb7d02e7b53fb5a835402e.tar.gz |
[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@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/expand.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr/dash/expand.c b/usr/dash/expand.c index 153f6b7a1b24c..e86bd29da60e3 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++; } |