tentatively fix Debian #878947 by putting an end to (some) nesting

‣ also makes the error message nicer:
tg@blau:/usr/obj/bin/mksh $ mksh -n -c '${0$(($(o[))&$(($(p[))&)'
internal error: can't allocate 8388628 data bytes
tg@blau:/usr/obj/bin/mksh $ mksh -n -c '${0$(($(o[))&$(($(p[))&)^J'
mksh: no closing quote
1|tg@blau:/usr/obj/bin/mksh $ ./mksh -n -c '${0$(($(o[))&$(($(p[))&)'
./mksh: syntax error: unmatched '('
1|tg@blau:/usr/obj/bin/mksh $ ./mksh -n -c '${0$(($(o[))&$(($(p[))&)^J'
./mksh: syntax error: unmatched '('

‣ alternative fix would be to keep the block and do…
-					} else {
+					} else if (source->type != SEOF) {
… but that would keep “no closing quote” for the case with newline,
and since this seems to not break… nuking unused code is always good ☻
This commit is contained in:
tg 2017-10-17 23:45:19 +00:00
parent c94bfd71e8
commit 0e478dceae
3 changed files with 6 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.798 2017/10/14 21:09:46 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.799 2017/10/17 23:45:16 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R56 2017/10/14
@(#)MIRBSD KSH R56 2017/10/17
description:
Check base version of full shell
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: !shell:legacy-yes
---
expected-stdout:
@(#)LEGACY KSH R56 2017/10/14
@(#)LEGACY KSH R56 2017/10/17
description:
Check base version of legacy shell
stdin:

11
lex.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.239 2017/05/05 22:53:29 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.240 2017/10/17 23:45:18 tg Exp $");
/*
* states while lexing word
@ -284,15 +284,6 @@ yylex(int cf)
}
afree(tmp, ATEMP);
break;
} else {
Source *s;
s = pushs(SREREAD,
source->areap);
s->start = s->str =
s->u.freeme = tmp;
s->next = source;
source = s;
}
}
*wp++ = CHAR;

4
sh.h
View File

@ -182,9 +182,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.848 2017/10/14 21:09:48 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.849 2017/10/17 23:45:19 tg Exp $");
#endif
#define MKSH_VERSION "R56 2017/10/14"
#define MKSH_VERSION "R56 2017/10/17"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES