summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Dekker2018-03-31 18:15:59 +0200
committerDenys Vlasenko2018-03-31 18:30:27 +0200
commitad4e961352f04ba88019c4c2bb36c652ce9c51fa (patch)
tree1c80d3ac8c42a9b204805d1506c7a76e3e7afa8a
parent7bf304f371ee08634d31a4e6b3cbd7d2d32e51d9 (diff)
downloadbusybox-ad4e961352f04ba88019c4c2bb36c652ce9c51fa.zip
busybox-ad4e961352f04ba88019c4c2bb36c652ce9c51fa.tar.gz
ash: 'nolog' and 'debug' options cause "$-" to wreak havoc
Upstream commit: Date: Tue Mar 6 17:40:37 2018 +0000 expand: 'nolog' and 'debug' options cause "$-" to wreak havoc 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> In bbox ash, pipefail is the option which exhibited this. Signed-off-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 8fb32c1..2ed802d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7192,7 +7192,7 @@ varvalue(char *name, int varflags, int flags, int *quotedp)
case '-':
expdest = makestrspace(NOPTS, expdest);
for (i = NOPTS - 1; i >= 0; i--) {
- if (optlist[i]) {
+ if (optlist[i] && optletters(i)) {
USTPUTC(optletters(i), expdest);
len++;
}