Message ID | Y47ZlpwkQy+jiule@gondor.apana.org.au (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Herbert Xu |
Headers | show |
Series | parser: Add VSBIT to ensure subtype is never zero | expand |
Hey. Is that already the final version of the patch? Cause then we could ping klibc sh / busybox about it. Thanks, Chris.
On Tue, Dec 06, 2022 at 04:19:39PM +0100, Christoph Anton Mitterer wrote: > > Is that already the final version of the patch? Cause then we could > ping klibc sh / busybox about it. Yes I will commit this to git soon. Thanks,
diff --git a/src/expand.c b/src/expand.c index aea5cc4..6bb1216 100644 --- a/src/expand.c +++ b/src/expand.c @@ -701,7 +701,7 @@ evalvar(char *p, int flag) int discard; int quoted; - varflags = *p++; + varflags = *p++ & ~VSBIT; subtype = varflags & VSTYPE; quoted = flag & EXP_QUOTED; diff --git a/src/parser.c b/src/parser.c index 13c2df5..b26f34a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1333,7 +1333,7 @@ badsub: synstack->dblquote = newsyn != BASESYNTAX; } - *((char *)stackblock() + typeloc) = subtype; + *((char *)stackblock() + typeloc) = subtype | VSBIT; if (subtype != VSNORMAL) { synstack->varnest++; if (synstack->dblquote) diff --git a/src/parser.h b/src/parser.h index 7d2749b..729c15c 100644 --- a/src/parser.h +++ b/src/parser.h @@ -50,6 +50,7 @@ /* variable substitution byte (follows CTLVAR) */ #define VSTYPE 0x0f /* type of variable substitution */ #define VSNUL 0x10 /* colon--treat the empty string as unset */ +#define VSBIT 0x20 /* Ensure subtype is not zero */ /* values of VSTYPE field */ #define VSNORMAL 0x1 /* normal variable: $var or ${var} */