From 0e199e6d061ca0bfd065eda131f7d24d717d3c04 Mon Sep 17 00:00:00 2001 From: ARYA MGC Date: Wed, 15 Jul 2026 22:05:29 +0530 Subject: [PATCH] Fix: strncpy() may leave pcWriteBuffer non-null-terminated in FreeRTOS_CLI.c (#1422) --- FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c index 783ed3b2ed..a4871375c5 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c @@ -201,6 +201,7 @@ BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, /* The command was found, but the number of parameters with the command * was incorrect. */ strncpy( pcWriteBuffer, "Incorrect command parameter(s). Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen ); + pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0'; pxCommand = NULL; } else if( pxCommand != NULL ) @@ -220,6 +221,7 @@ BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, { /* pxCommand was NULL, the command was not found. */ strncpy( pcWriteBuffer, "Command not recognised. Enter 'help' to view a list of available commands.\r\n\r\n", xWriteBufferLen ); + pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0'; xReturn = pdFALSE; } @@ -340,6 +342,7 @@ static BaseType_t prvHelpCommand( char * pcWriteBuffer, /* Return the next command help string, before moving the pointer on to * the next command in the list. */ strncpy( pcWriteBuffer, pxCommand->pxCommandLineDefinition->pcHelpString, xWriteBufferLen ); + pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0'; pxCommand = pxCommand->pxNext; if( pxCommand == NULL )