]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1680: MS-Windows: possible buffer-under run in if_cscope v9.1.1680
authorChristian Brabandt <cb@256bit.org>
Sat, 23 Aug 2025 16:11:28 +0000 (18:11 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 23 Aug 2025 16:11:28 +0000 (18:11 +0200)
Problem:  MS-Windows: possible buffer-under run in if_cscope
          cs_pathcomponents() (Murali Aniruddhan)
Solution: Fix the loop and do not decrement the pointer twice.

closes: #18091

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/if_cscope.c
src/version.c

index 86bfbd81b8208fd36464dfee4aad6338c4413d70..478a99f16da28b4ffd77a7ad0f92afc2f9a96521 100644 (file)
@@ -1940,12 +1940,18 @@ cs_pathcomponents(char *path)
 
     s = path + strlen(path) - 1;
     for (i = 0; i < p_cspc; ++i)
-       while (s > path && *--s != '/'
+    {
+       while (s > path)
+       {
+          s--;
+          if (*s == '/'
 #ifdef MSWIN
-               && *--s != '\\'
+               || *s == '\\'
 #endif
                )
-           ;
+             break;
+       }
+    }
     if ((s > path && *s == '/')
 #ifdef MSWIN
        || (s > path && *s == '\\')
index 98ecbc99a893e3e072429b0069f56a3a5c1e6720..a53a039243d44485ee1b064dd41f2a7381ca4e0f 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1680,
 /**/
     1679,
 /**/