Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh Fix core dump caused by



details:   https://anonhg.NetBSD.org/src/rev/b593e46aa4ba
branches:  trunk
changeset: 368286:b593e46aa4ba
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Jul 03 06:30:31 2022 +0000

description:
Fix core dump caused by
        ksh -c '(i=10; echo $((++-+++i)))'
reported by Steffen Nurpmeso (not on a NetBSD list or PR).

Seems pointless to fix just one of the bugs in this thing, but this one was
easy enough (and stupid enough).   (The "i=10" part is unimportant, as is the sub-shell).

diffstat:

 bin/ksh/expr.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 7acbfc81890e -r b593e46aa4ba bin/ksh/expr.c
--- a/bin/ksh/expr.c    Sat Jul 02 20:50:26 2022 +0000
+++ b/bin/ksh/expr.c    Sun Jul 03 06:30:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $  */
+/*     $NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $    */
 
 /*
  * Korn expression evaluation
@@ -9,7 +9,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $");
 #endif
 
 
@@ -311,6 +311,8 @@
                        token(es);
                } else if (op == O_PLUSPLUS || op == O_MINUSMINUS) {
                        token(es);
+                       if (es->tok != VAR)
+                               evalerr(es, ET_LVALUE, opinfo[(int) op].name);
                        vl = do_ppmm(es, op, es->val, true);
                        token(es);
                } else if (op == VAR || op == LIT) {



Home | Main Index | Thread Index | Old Index