• save/restore here document pointer during yyrecursive(), fixes crash

• add mirbsd/openbsd (omalloc rules!) specific testcase for the above
• $__progname must be used quoted, fix in comsub-torture testcase (my bad)
This commit is contained in:
tg 2011-03-21 21:57:35 +00:00
parent 3c41d2b063
commit bc4c3b9af0
3 changed files with 21 additions and 8 deletions

20
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.430 2011/03/17 22:09:20 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.431 2011/03/21 21:57:32 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2011/03/17
@(#)MIRBSD KSH R39 2011/03/21
description:
Check version of shell.
stdin:
@ -7040,13 +7040,13 @@ stdin:
if (( lastf )); then
x="inline_${nextf}() {"$fbody$'\n}\n'
print -nr -- "$x"
print -r -- "${x}typeset -f inline_$nextf" | $__progname
print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f comsub_$nextf" | $__progname
print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f reread_$nextf" | $__progname
print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
fi
lastf=1
fbody=
@ -8384,3 +8384,13 @@ expected-stdout:
24 ?lnnix/nix =lnnix/nix: No such file or directory !2
25 ?lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself =lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself: Too many levels of symbolic links !62
---
name: crash-1
description:
Crashed during March 2011, fixed on vernal equinōx
category: os:mirbsd,os:openbsd
stdin:
export MALLOC_OPTIONS=FGJPRSX
"$__progname" -c 'x=$(tr z r <<<baz); echo $x'
expected-stdout:
bar
---

4
sh.h
View File

@ -154,9 +154,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.449 2011/03/17 22:09:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.450 2011/03/21 21:57:33 tg Exp $");
#endif
#define MKSH_VERSION "R39 2011/03/17"
#define MKSH_VERSION "R39 2011/03/21"
#ifndef MKSH_INCLUDES_ONLY

5
syn.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.57 2011/03/13 16:03:54 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.58 2011/03/21 21:57:35 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -1097,6 +1097,7 @@ yyrecursive(void)
char *cp;
bool old_reject;
int old_symbol;
struct ioword **old_herep;
extern short comsub_nesting_level;
/* tell the lexer to accept a closing parenthesis as EOD */
@ -1106,8 +1107,10 @@ yyrecursive(void)
old_reject = reject;
old_symbol = symbol;
ACCEPT;
old_herep = herep;
/* we use TPAREN as a helper container here */
t = nested(TPAREN, '(', ')');
herep = old_herep;
reject = old_reject;
symbol = old_symbol;