From 191d77872d8938fce28abaec061d4d6cde88cf48 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sat, 23 Aug 2025 18:11:28 +0200 Subject: [PATCH] patch 9.1.1680: MS-Windows: possible buffer-under run in if_cscope 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 --- src/if_cscope.c | 12 +++++++++--- src/version.c | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/if_cscope.c b/src/if_cscope.c index 86bfbd81b8..478a99f16d 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -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 == '\\') diff --git a/src/version.c b/src/version.c index 98ecbc99a8..a53a039243 100644 --- a/src/version.c +++ b/src/version.c @@ -724,6 +724,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1680, /**/ 1679, /**/