From b24d545294507a5af5a63880282247042d934c9e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 10 Jan 2008 18:53:49 +0000 Subject: users/12412: check for extra arguments in test and [ --- Src/builtin.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index 8ded1c131..299ad3758 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5472,7 +5472,7 @@ zread(int izle, int *readchar) /* holds arguments for testlex() */ /**/ -char **testargs; +char **testargs, **curtestarg; /* test, [: the old-style general purpose logical expression builtin */ @@ -5483,7 +5483,7 @@ testlex(void) if (tok == LEXERR) return; - tokstr = *testargs; + tokstr = *(curtestarg = testargs); if (!*testargs) { /* if tok is already zero, reading past the end: error */ tok = tok ? NULLTOK : LEXERR; @@ -5557,6 +5557,11 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func) return 1; } + if (*curtestarg) { + zwarnnam(name, "too many arguments"); + return 1; + } + /* syntax is OK, so evaluate */ state.prog = prog; -- cgit 1.4.1