examples: Fix checking id parameter in thread_start

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 <fberder@outlook.fr>
This commit is contained in:
Francois Berder
2025-11-22 21:45:02 +01:00
committed by Tom Rini
parent 1c1be32c31
commit 43ca62bf19

View File

@@ -261,9 +261,8 @@ static void thread_launcher (void)
static int thread_start (int id) static int thread_start (int id)
{ {
PDEBUG ("thread_start: id=%d", id); PDEBUG ("thread_start: id=%d", id);
if (id <= MASTER_THREAD || id > MAX_THREADS) { if (id <= MASTER_THREAD || id >= MAX_THREADS)
return RC_FAILURE; return RC_FAILURE;
}
if (lthreads[id].state != STATE_STOPPED) if (lthreads[id].state != STATE_STOPPED)
return RC_FAILURE; return RC_FAILURE;