diff options
| author | Meco Man <[email protected]> | 2024-03-27 18:39:40 -0400 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-04-16 22:29:47 -0400 |
| commit | 1ea1c8fc7bacd167c3041ab088dba031dca456b4 (patch) | |
| tree | a6170d8870003747ed705ab838ce9e77bda19eae | |
| parent | ac38532aebdab7bb0f6f9fdcb96be1a8bb118c97 (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; } |
