Patch 8.2.4963

8 views
Skip to first unread message

Bram Moolenaar

unread,
May 16, 2022, 7:41:37 AM5/16/22
to vim...@googlegroups.com

Patch 8.2.4963
Problem: Expanding path with "/**" may overrun end of buffer.
Solution: Use vim_snprintf().
Files: src/filepath.c


*** ../vim-8.2.4962/src/filepath.c 2022-05-09 20:09:19.286641426 +0100
--- src/filepath.c 2022-05-16 12:33:32.106956008 +0100
***************
*** 3589,3594 ****
--- 3589,3595 ----
int didstar) // expanded "**" once already
{
char_u *buf;
+ size_t buflen;
char_u *path_end;
char_u *p, *s, *e;
int start_len = gap->ga_len;
***************
*** 3612,3618 ****
}

// make room for file name
! buf = alloc(STRLEN(path) + BASENAMELEN + 5);
if (buf == NULL)
return 0;

--- 3613,3620 ----
}

// make room for file name
! buflen = STRLEN(path) + BASENAMELEN + 5;
! buf = alloc(buflen);
if (buf == NULL)
return 0;

***************
*** 3737,3750 ****
{
// For "**" in the pattern first go deeper in the tree to
// find matches.
! STRCPY(buf + len, "/**");
! STRCPY(buf + len + 3, path_end);
++stardepth;
(void)unix_expandpath(gap, buf, len + 1, flags, TRUE);
--stardepth;
}

! STRCPY(buf + len, path_end);
if (mch_has_exp_wildcard(path_end)) // handle more wildcards
{
// need to expand another component of the path
--- 3739,3752 ----
{
// For "**" in the pattern first go deeper in the tree to
// find matches.
! vim_snprintf((char *)buf + len, buflen - len,
! "/**%s", path_end);
++stardepth;
(void)unix_expandpath(gap, buf, len + 1, flags, TRUE);
--stardepth;
}

! 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
*** ../vim-8.2.4962/src/version.c 2022-05-16 11:14:05.106515306 +0100
--- src/version.c 2022-05-16 12:34:26.894908947 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4963,
/**/

--
hundred-and-one symptoms of being an internet addict:
211. Your husband leaves you...taking the computer with him and you
call him crying, and beg him to bring the computer back.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages