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 <xiaoxiang@xiaomi.com>
Change-Id: I527001af08da0865c4054b7a5b6ccaf60f585c06
This commit is contained in:
Xiang Xiao 2020-09-03 22:40:10 +08:00 committed by Alin Jerpelea
parent bef5dc32a7
commit 3edfb4a3ac

View File

@ -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';
}