From b34499f5c851d1a70db95b56bd02eff0329d4a1a Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 23 Aug 2013 21:58:55 +1000 Subject: [BUILTIN] Fixed argument parsing crash in test When nexpr gets an unexpected EOI, this may cause crashes further up the call chain because we've advanced t_wp too far. Fix it by checking for EOI in nexpr and only advancing t_wp if we've got more arguments. Signed-off-by: Herbert Xu --- src/bltin/test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/bltin/test.c') diff --git a/src/bltin/test.c b/src/bltin/test.c index 90135e1..baa91a5 100644 --- a/src/bltin/test.c +++ b/src/bltin/test.c @@ -268,9 +268,13 @@ aexpr(enum token n) static int nexpr(enum token n) { - if (n == UNOT) - return !nexpr(t_lex(++t_wp)); - return primary(n); + if (n != UNOT) + return primary(n); + + n = t_lex(t_wp + 1); + if (n != EOI) + t_wp++; + return !nexpr(n); } static int -- cgit 1.4.1