From 4157cca352b31a8bacd86fa7021e136077c7a5cd Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 13 Feb 2015 12:51:33 +0000 Subject: [PATCH] oksh sync; unsure if it applies (with us using old_source and all) but better be safe than sorry; it at least passes our testsuite NOTE: people who can figure out how afl can be used for mksh welcome! ;-) --- check.t | 6 +++--- main.c | 11 +++++++++-- sh.h | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/check.t b/check.t index 5336b61..e00c9d3 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.678 2015/02/06 10:56:44 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.679 2015/02/13 12:51:30 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -30,7 +30,7 @@ # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date expected-stdout: - @(#)MIRBSD KSH R50 2015/02/06 + @(#)MIRBSD KSH R50 2015/02/13 description: Check version of shell. stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R50 2015/02/06 + @(#)LEGACY KSH R50 2015/02/13 description: Check version of legacy shell. stdin: diff --git a/main.c b/main.c index 6a5c191..38b8165 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.54 2013/11/28 10:33:37 sobrado Exp $ */ +/* $OpenBSD: main.c,v 1.55 2015/02/09 09:09:30 jsg Exp $ */ /* $OpenBSD: tty.c,v 1.10 2014/08/10 02:44:26 guenther Exp $ */ /* $OpenBSD: io.c,v 1.25 2014/08/11 20:28:47 guenther Exp $ */ /* $OpenBSD: table.c,v 1.15 2012/02/19 07:52:30 otto Exp $ */ @@ -34,7 +34,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.286 2014/11/25 21:13:28 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.287 2015/02/13 12:51:31 tg Exp $"); extern char **environ; @@ -892,6 +892,13 @@ unwind(int i) /* FALLTHROUGH */ default: quitenv(NULL); + /* + * quitenv() may have reclaimed the memory + * used by source which will end badly when + * we jump to a function that expects it to + * be valid + */ + source = NULL; } } } diff --git a/sh.h b/sh.h index c09f38f..f4f8b35 100644 --- a/sh.h +++ b/sh.h @@ -169,9 +169,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.710 2015/02/06 10:56:48 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.711 2015/02/13 12:51:33 tg Exp $"); #endif -#define MKSH_VERSION "R50 2015/02/06" +#define MKSH_VERSION "R50 2015/02/13" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES