From 3edfb4a3acc0d01838d01367c2f5f7da9b1db57f Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 3 Sep 2020 22:40:10 +0800 Subject: [PATCH] system/readline: Fix the stack overflow when application name is too long shouldn't zero the memory after tmp_name Signed-off-by: Xiang Xiao Change-Id: I527001af08da0865c4054b7a5b6ccaf60f585c06 --- system/readline/readline_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/readline/readline_common.c b/system/readline/readline_common.c index 4fe7c6c0b..13750fe8e 100644 --- a/system/readline/readline_common.c +++ b/system/readline/readline_common.c @@ -302,7 +302,7 @@ static void tab_completion(FAR struct rl_common_s *vtbl, char *buf, * matches. */ - if (name[j] != tmp_name[j]) + if (j < sizeof(tmp_name) && name[j] != tmp_name[j]) { tmp_name[j] = '\0'; } @@ -337,7 +337,7 @@ static void tab_completion(FAR struct rl_common_s *vtbl, char *buf, * matches. */ - if (name[j] != tmp_name[j]) + if (j < sizeof(tmp_name) && name[j] != tmp_name[j]) { tmp_name[j] = '\0'; }