summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorseteiro <[email protected]>2026-11-14 18:30:12 +0800
committerRbb666 <[email protected]>2026-11-17 11:33:50 +0800
commit4c8232815e43169e25cbcc217efdd36ee2cb64a0 (patch)
tree315b716cb407fe6cfc7e8e2ecd692b2c7499f526 /components
parent9ddb0249c0bf022f8d5efc9ff20d407247e5602d (diff)
[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.
Diffstat (limited to 'components')
-rw-r--r--components/finsh/msh.c5
1 files changed, 5 insertions, 0 deletions
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 */