klibc-bot for Herbert Xu
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: [BUILTIN] Fixed argument parsing crash in test
Commit-ID: f82f85d8be5ced5e6728792fea1a6dc089decf59 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=f82f85d8be5ced5e6728792fea1a6dc089decf59 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Fri, 23 Aug 2013 21:58:55 +1000 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [BUILTIN] Fixed argument parsing crash in test [ dash commit b34499f5c851d1a70db95b56bd02eff0329d4a1a ] 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 <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/bltin/test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr/dash/bltin/test.c b/usr/dash/bltin/test.c index 90135e14..baa91a57 100644 --- a/usr/dash/bltin/test.c +++ b/usr/dash/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
Seemingly Similar Threads
- [klibc:update-dash] [BUILTIN] Fixed argument parsing crash in test
- [klibc:update-dash] [BUILTIN] Correctly handle test ! ! = !
- [klibc:update-dash] dash: [BUILTIN] Correctly handle test ! ! = !
- [git pull v4] dash, sh4, ipconfig, dprintf, fstype, README's
- [PATCH] pull faccessat() system call