lthreads is of size MAX_THREADS, hence id must be lower than
MAX_THREADS to avoid any potential buffer overflow in
thread_start function.

Signed-off-by: Francois Berder <[email protected]>
---
 examples/standalone/sched.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/standalone/sched.c b/examples/standalone/sched.c
index 57ae67e1a5b..64518c6890f 100644
--- a/examples/standalone/sched.c
+++ b/examples/standalone/sched.c
@@ -261,9 +261,8 @@ static void thread_launcher (void)
 static int thread_start (int id)
 {
        PDEBUG ("thread_start: id=%d", id);
-       if (id <= MASTER_THREAD || id > MAX_THREADS) {
+       if (id <= MASTER_THREAD || id >= MAX_THREADS)
                return RC_FAILURE;
-       }
 
        if (lthreads[id].state != STATE_STOPPED)
                return RC_FAILURE;
-- 
2.43.0


Reply via email to