From d9cccec2ed5c71a759f6f2b7198554d6e98fd22c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 17 Dec 2014 12:24:02 -0600 Subject: strncpy will not copy the terminating \0 into the destination if the source is larger than the size of the destination. Ensure that the last byte is always zero and let strncpy only copy CONFIG_TASK_NAME_SIZE bytes. The issue of unterminated names can be observed in ps when creating a pthread while CONFIG_TASK_NAME_SIZE is set to 8. --- nuttx/include/nuttx/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nuttx/include') diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h index 563773ec1..fa0810711 100644 --- a/nuttx/include/nuttx/sched.h +++ b/nuttx/include/nuttx/sched.h @@ -536,7 +536,7 @@ struct tcb_s struct xcptcontext xcp; /* Interrupt register save area */ #if CONFIG_TASK_NAME_SIZE > 0 - char name[CONFIG_TASK_NAME_SIZE]; /* Task name */ + char name[CONFIG_TASK_NAME_SIZE+1]; /* Task name (with NUL terminator) */ #endif }; -- cgit v1.2.3