From 4c8232815e43169e25cbcc217efdd36ee2cb64a0 Mon Sep 17 00:00:00 2001 From: seteiro <276597748+cms19859230182-lang@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:30:12 +0800 Subject: [finsh] bound path auto-complete buffer copies Fix #11839 In msh_auto_complete_path(), when the user inputs an excessively long path string that exceeds DFS_PATH_MAX, attempting to concatenate and resolve directory components in the fixed-size full_path buffer could trigger a heap buffer overflow. Check that the input path length does not exceed DFS_PATH_MAX before allocating the buffer and attempting path resolution, aborting completion safely when input is oversized. --- components/finsh/msh.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'components') diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 4adb05c918..c7e7a27dcc 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -640,6 +640,11 @@ void msh_auto_complete_path(char *path, rt_size_t path_size) return; } + if (rt_strlen(path) >= DFS_PATH_MAX) + { + return; + } + full_path = (char *)rt_malloc(DFS_PATH_MAX); if (full_path == RT_NULL) return; /* out of memory */ -- cgit v1.3.1