Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: core dump or infinite loop in brace expansion



On 2014/06/11, at 10:05, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Seems like the right thing would be to make bracechardots() agree with
> xpandbraces().


Thanks. With a few more testing, I've found that we need to take care
of the 'cend' part also:

zsh% print -r {x..{} 
 glob.c:2180: BUG: unmatched brace in xpandbraces()
x y z {

I also tested with other "special" characters '}', ',' and '.',
but didn't find any problem:

zsh% print -r {\}..~}
} ~
zsh% print -r {}..~}
zsh: parse error near `}'
zsh% print -r {...2}          # {\...2} gives the same result
. / 0 1 2
zsh% print -r {#...}
# $ % & ' ( ) * + , - .
zsh% print -r {...,}
...
zsh% print -r {...\,}
. - ,




diff --git a/Src/glob.c b/Src/glob.c
index 15a5f70..3ae364c 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2122,6 +2122,8 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
     convchar_t cstart, cend;
     char *pnext = str + 1, *pconv, convstr[2];
     if (itok(*pnext)) {
+	if (*pnext == Inbrace)
+	    return 0;
 	convstr[0] = ztokens[*pnext - Pound];
 	convstr[1] = '\0';
 	pconv = convstr;
@@ -2133,6 +2135,8 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
 	return 0;
     pnext += 2;
     if (itok(*pnext)) {
+	if (*pnext == Inbrace)
+	    return 0;
 	convstr[0] = ztokens[*pnext - Pound];
 	convstr[1] = '\0';
 	pconv = convstr;





Messages sorted by: Reverse Date, Date, Thread, Author