Skip to content

Commit 475fc91

Browse files
ycsinnashif
authored andcommitted
shell: modules: kernel: add additional check in unwind cmd
Use `shell_strtoull()` to parse the thread ID argument for error checking. Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent e3c2e84 commit 475fc91

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/shell/modules/kernel_service.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,16 @@ static bool print_trace_address(void *arg, unsigned long ra)
324324
static int cmd_kernel_thread_unwind(const struct shell *sh, size_t argc, char **argv)
325325
{
326326
struct k_thread *thread;
327+
int err = 0;
327328

328329
if (argc == 1) {
329330
thread = _current;
330331
} else {
331-
thread = UINT_TO_POINTER(strtoll(argv[1], NULL, 16));
332+
thread = UINT_TO_POINTER(shell_strtoull(argv[1], 16, &err));
333+
if (err != 0) {
334+
shell_error(sh, "Unable to parse thread ID %s (err %d)", argv[1], err);
335+
return err;
336+
}
332337

333338
if (!thread_is_valid(thread)) {
334339
shell_error(sh, "Invalid thread id %p", (void *)thread);

0 commit comments

Comments
 (0)