From bbf00b5d9391ceaf585e035c06a2453c7631b9f4 Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 8 Jun 2009 20:13:07 +0000 Subject: [PATCH] merge fix from oksh: "let --" was crashing ksh; found by phy0@rambler.ru. Various other expressions involving ++ and -- also ran into this. Insufficient checks for end of parse in the tokenizer made it assume that an lvalue had been found --- expr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/expr.c b/expr.c index 1e543d0..33d8f22 100644 --- a/expr.c +++ b/expr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expr.c,v 1.19 2006/04/10 14:38:59 jaredy Exp $ */ +/* $OpenBSD: expr.c,v 1.21 2009/06/01 19:00:57 deraadt Exp $ */ /*- * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009 @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.27 2009/06/08 20:06:45 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.28 2009/06/08 20:13:07 tg Exp $"); /* The order of these enums is constrained by the order of opinfo[] */ enum token { @@ -592,7 +592,8 @@ do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool is_prefix) static void assign_check(Expr_state *es, enum token op, struct tbl *vasn) { - if (vasn->name[0] == '\0' && !(vasn->flag & EXPRLVALUE)) + if (es->tok == END || + (vasn->name[0] == '\0' && !(vasn->flag & EXPRLVALUE))) evalerr(es, ET_LVALUE, opinfo[(int)op].name); else if (vasn->flag & RDONLY) evalerr(es, ET_RDONLY, opinfo[(int)op].name);