diff options
Diffstat (limited to 'nuttx/sched')
-rw-r--r-- | nuttx/sched/Kconfig | 6 | ||||
-rw-r--r-- | nuttx/sched/init/os_start.c | 3 | ||||
-rw-r--r-- | nuttx/sched/pthread/pthread_create.c | 1 | ||||
-rw-r--r-- | nuttx/sched/task/task_prctl.c | 3 | ||||
-rw-r--r-- | nuttx/sched/task/task_setup.c | 1 |
5 files changed, 10 insertions, 4 deletions
diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig index 62bc6accb..10b34fe01 100644 --- a/nuttx/sched/Kconfig +++ b/nuttx/sched/Kconfig @@ -297,11 +297,13 @@ config RR_INTERVAL config TASK_NAME_SIZE int "Maximum task name size" - default 32 + default 31 ---help--- Spcifies that maximum size of a task name to save in the TCB. Useful if scheduler instrumentation is selected. Set to zero to - disable. + disable. Excludes the NUL terminator; the actual allocated size + willl be TASK_NAME_SIZE + 1. The default of 31 then results in + a align-able 32-byte allocation.:: config MAX_TASKS int "Max number of tasks" diff --git a/nuttx/sched/init/os_start.c b/nuttx/sched/init/os_start.c index 561e79b9b..fcb305180 100644 --- a/nuttx/sched/init/os_start.c +++ b/nuttx/sched/init/os_start.c @@ -307,7 +307,8 @@ void os_start(void) /* Set the IDLE task name */ #if CONFIG_TASK_NAME_SIZE > 0 - strncpy(g_idletcb.cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE-1); + strncpy(g_idletcb.cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE); + g_idletcb.cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; #endif /* CONFIG_TASK_NAME_SIZE */ /* Configure the task name in the argument list. The IDLE task does diff --git a/nuttx/sched/pthread/pthread_create.c b/nuttx/sched/pthread/pthread_create.c index 70c00a447..8cfab5908 100644 --- a/nuttx/sched/pthread/pthread_create.c +++ b/nuttx/sched/pthread/pthread_create.c @@ -115,6 +115,7 @@ static inline void pthread_argsetup(FAR struct pthread_tcb_s *tcb, pthread_addr_ /* Copy the pthread name into the TCB */ strncpy(tcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE); + tcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; #endif /* CONFIG_TASK_NAME_SIZE */ /* For pthreads, args are strictly pass-by-value; that actual diff --git a/nuttx/sched/task/task_prctl.c b/nuttx/sched/task/task_prctl.c index b0e00f316..5bbac6b9f 100644 --- a/nuttx/sched/task/task_prctl.c +++ b/nuttx/sched/task/task_prctl.c @@ -133,9 +133,10 @@ int prctl(int option, ...) if (option == PR_SET_NAME) { - /* tcb->name may not be null-terminated */ + /* Ensure that tcb->name will be null-terminated, truncating if necessary */ strncpy(tcb->name, name, CONFIG_TASK_NAME_SIZE); + tcb->name[CONFIG_TASK_NAME_SIZE] = '\0'; } else { diff --git a/nuttx/sched/task/task_setup.c b/nuttx/sched/task/task_setup.c index 1b838eea3..5474c9126 100644 --- a/nuttx/sched/task/task_setup.c +++ b/nuttx/sched/task/task_setup.c @@ -426,6 +426,7 @@ static void task_namesetup(FAR struct task_tcb_s *tcb, FAR const char *name) /* Copy the name into the TCB */ strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE); + tcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; } #else # define task_namesetup(t,n) |