[msh] solve data access bugs and fix shell.c strcat()

When using musl libc's strcat, strcat itself will cause system crash.
This commit is contained in:
Meco Man 2024-03-27 18:39:40 -04:00
parent 61c1041d47
commit e0f2313c53
1 changed files with 5 additions and 1 deletions

View File

@ -112,7 +112,11 @@ const char *finsh_get_prompt(void)
getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
#endif
strcat(finsh_prompt, ">");
if (rt_strlen(finsh_prompt) + 2 < RT_CONSOLEBUF_SIZE)
{
finsh_prompt[rt_strlen(finsh_prompt)] = '>';
finsh_prompt[rt_strlen(finsh_prompt) + 1] = '\0';
}
return finsh_prompt;
}