From bc265d74e768ffd0a8d70e88f3f31387f66542e4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 13 Nov 2014 06:44:15 -0600 Subject: [PATCH] task_create: Don't even try if the accumulated size of the argument list is larger than the stack --- sched/task/task_setup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c index 7320cf19d5..03ee33017c 100644 --- a/sched/task/task_setup.c +++ b/sched/task/task_setup.c @@ -490,9 +490,16 @@ static inline int task_stackargsetup(FAR struct task_tcb_s *tcb, while (argv[argc]) { - /* Add the size of this argument (with NUL terminator) */ + /* Add the size of this argument (with NUL terminator). + * Check each time if the accumulated size exceeds the + * size of the allocated stack. + */ strtablen += (strlen(argv[argc]) + 1); + if (strtablen >= tcb->adj_stack_size) + { + return -ENAMETOOLONG; + } /* Increment the number of args. Here is a sanity check to * prevent running away with an unterminated argv[] list.