From b116ed7b126ebcb987c196971cce87625a441a73 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 27 Aug 2025 10:17:30 +0800 Subject: [PATCH] vim-patch:9.1.1690: Missing recursion guard in dos/unix_expandpath() (#35499) Problem: Missing recursion guard in dos/unix_expandpath() Solution: Add guard variables (ashamedbit) fixes: vim/vim#18099 closes: vim/vim#18106 https://github.com/vim/vim/commit/e8948a1f807cb595446e896e00bdf0e5339f0dd2 Co-authored-by: ashamedbit Co-authored-by: Hirohito Higashi --- src/nvim/path.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nvim/path.c b/src/nvim/path.c index 941939dc8e..d2170ecd3b 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -754,9 +754,13 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in vim_snprintf(buf + len, buflen - len, "%s", path_end); if (path_has_exp_wildcard(path_end)) { // handle more wildcards - // need to expand another component of the path - // remove backslashes for the remaining components only - do_path_expand(gap, buf, len + 1, flags, false); + if (stardepth < 100) { + stardepth++; + // need to expand another component of the path + // remove backslashes for the remaining components only + do_path_expand(gap, buf, len + 1, flags, false); + stardepth--; + } } else { FileInfo file_info;