This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new dbf7d34a2 nsh: Fix a potential buffer overflow in cmd help
dbf7d34a2 is described below

commit dbf7d34a2af383da0e3b24e58c2834f9f2d87e37
Author: Huang Qi <huang...@xiaomi.com>
AuthorDate: Wed Mar 8 20:56:16 2023 +0800

    nsh: Fix a potential buffer overflow in cmd help
    
    Follow https://github.com/apache/nuttx-apps/pull/1621, fix issue of builtin 
command list.
    
    Signed-off-by: Huang Qi <huang...@xiaomi.com>
---
 nshlib/nsh_command.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index f4f9c656b..e5ff25289 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -813,7 +813,11 @@ static inline void help_builtins(FAR struct nsh_vtbl_s 
*vtbl)
   unsigned int j;
   unsigned int k;
   unsigned int offset;
-  char line[HELP_LINELEN];
+
+  /* Extra 5 bytes for tab before newline and '\0' */
+
+  char line[HELP_LINELEN + HELP_TABSIZE + 1];
+
   static const char *g_builtin_prompt = "\nBuiltin Apps:\n";
 
   /* Count the number of built-in commands and get the optimal column width */

Reply via email to