Skip to content

Commit 191d778

Browse files
committed
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: vim#18091 Signed-off-by: Christian Brabandt <[email protected]>
1 parent ba9551d commit 191d778

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/if_cscope.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,12 +1940,18 @@ cs_pathcomponents(char *path)
19401940

19411941
s = path + strlen(path) - 1;
19421942
for (i = 0; i < p_cspc; ++i)
1943-
while (s > path && *--s != '/'
1943+
{
1944+
while (s > path)
1945+
{
1946+
s--;
1947+
if (*s == '/'
19441948
#ifdef MSWIN
1945-
&& *--s != '\\'
1949+
|| *s == '\\'
19461950
#endif
19471951
)
1948-
;
1952+
break;
1953+
}
1954+
}
19491955
if ((s > path && *s == '/')
19501956
#ifdef MSWIN
19511957
|| (s > path && *s == '\\')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ static char *(features[]) =
724724

725725
static int included_patches[] =
726726
{ /* Add new patch number below this line */
727+
/**/
728+
1680,
727729
/**/
728730
1679,
729731
/**/

0 commit comments

Comments
 (0)