klibc-bot for Herbert Xu
2019-Jan-25 03:15 UTC
[klibc] [klibc:update-dash] [BUILTIN] Fixed argument parsing crash in test
Commit-ID: 5374f1712c3821ac009821c6ec43c537171372f4
Gitweb:
http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=5374f1712c3821ac009821c6ec43c537171372f4
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: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] [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 <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
Reasonably Related Threads
- [klibc:update-dash] 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
- [git pull] dash, sh4, README's
