diff options
| author | Meco Man <[email protected]> | 2024-03-27 18:39:40 -0400 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-03-27 18:40:56 -0400 |
| commit | e0f2313c534eda75512d7b07398de3e72292209d (patch) | |
| tree | 179f08b50fa4d01bfbb00ac471d01591f2757ae3 | |
| parent | 61c1041d47153c1b53ed92bfe5a09f1da55a350b (diff) | |
[msh] solve data access bugs and fix shell.c strcat()
When using musl libc's strcat, strcat itself will cause system crash.
| -rw-r--r-- | components/finsh/shell.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c index b21b314525..e698edd51f 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -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; } |
