]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1690: Missing recursion guard in dos/unix_expandpath() v9.1.1690
authorashamedbit <muralianiruddhan@gmail.com>
Tue, 26 Aug 2025 15:43:18 +0000 (17:43 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 26 Aug 2025 15:43:18 +0000 (17:43 +0200)
Problem:  Missing recursion guard in dos/unix_expandpath()
Solution: Add guard variables (ashamedbit)

fixes: #18099
closes: #18106

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: ashamedbit <muralianiruddhan@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/filepath.c
src/version.c

index 7d115eeda6eac648b55b80dde9dbe59d74d75c22..d8a1dce742777e0edca3a73ac6957aa072e99bb4 100644 (file)
@@ -3709,9 +3709,14 @@ dos_expandpath(
                vim_snprintf((char *)buf + len, buflen - len, "%s", path_end);
                if (mch_has_exp_wildcard(path_end))
                {
-                   // need to expand another component of the path
-                   // remove backslashes for the remaining components only
-                   (void)dos_expandpath(gap, buf, len + 1, flags, FALSE);
+                   if (stardepth < 100)
+                   {
+                       // need to expand another component of the path
+                       // remove backslashes for the remaining components only
+                       ++stardepth;
+                       (void)dos_expandpath(gap, buf, len + 1, flags, FALSE);
+                       --stardepth;
+                   }
                }
                else
                {
@@ -3950,9 +3955,14 @@ unix_expandpath(
                vim_snprintf((char *)buf + len, buflen - len, "%s", path_end);
                if (mch_has_exp_wildcard(path_end)) // handle more wildcards
                {
-                   // need to expand another component of the path
-                   // remove backslashes for the remaining components only
-                   (void)unix_expandpath(gap, buf, len + 1, flags, FALSE);
+                   if (stardepth < 100)
+                   {
+                       // need to expand another component of the path
+                       // remove backslashes for the remaining components only
+                       ++stardepth;
+                       (void)unix_expandpath(gap, buf, len + 1, flags, FALSE);
+                       --stardepth;
+                   }
                }
                else
                {
index bedb8ec0bd30f963344a3b7adab14229e3c2f12f..b0ce4f31108a0986cfb3a8fee627c08fdb325315 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1690,
 /**/
     1689,
 /**/