From 4cd4303c321e20153b3b63d2c55d0c7e25e9dc22 Mon Sep 17 00:00:00 2001 From: xiangdong6 Date: Sat, 3 Sep 2022 13:10:23 +0800 Subject: [PATCH] binfmt: Check return pointer. Function builtin_for_index may return NULL. We must check this to prevent visit invalid address. Signed-off-by: xiangdong6 --- binfmt/builtin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/binfmt/builtin.c b/binfmt/builtin.c index a7a85d9a53..9ba1b59d8a 100644 --- a/binfmt/builtin.c +++ b/binfmt/builtin.c @@ -97,6 +97,12 @@ static int builtin_loadbinary(FAR struct binary_s *binp, */ builtin = builtin_for_index(index); + if (builtin == NULL) + { + berr("ERROR: %s is not a builtin application\n", filename); + return -ENOENT; + } + binp->entrypt = builtin->main; binp->stacksize = builtin->stacksize; binp->priority = builtin->priority;