mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
vim-patch:8.2.4963: expanding path with "/**" may overrun end of buffer
Problem: Expanding path with "/**" may overrun end of buffer. Solution: Use vim_snprintf().386c24cd26
Co-authored-by: Bram Moolenaar <Bram@vim.org> (cherry picked from commitad5bced637
)
This commit is contained in:
committed by
github-actions[bot]
parent
c5eeb1b9ee
commit
52ad6adc8d
@ -633,7 +633,8 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
|
||||
// Make room for file name. When doing encoding conversion the actual
|
||||
// length may be quite a bit longer, thus use the maximum possible length.
|
||||
char *buf = xmalloc(MAXPATHL);
|
||||
const size_t buflen = MAXPATHL;
|
||||
char *buf = xmalloc(buflen);
|
||||
|
||||
// Find the first part in the path name that contains a wildcard.
|
||||
// When EW_ICASE is set every letter is considered to be a wildcard.
|
||||
@ -751,14 +752,13 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
if (starstar && stardepth < 100) {
|
||||
// For "**" in the pattern first go deeper in the tree to
|
||||
// find matches.
|
||||
STRCPY(buf + len, "/**"); // NOLINT
|
||||
STRCPY(buf + len + 3, path_end);
|
||||
vim_snprintf(buf + len, buflen - len, "/**%s", path_end); // NOLINT
|
||||
stardepth++;
|
||||
do_path_expand(gap, buf, len + 1, flags, true);
|
||||
stardepth--;
|
||||
}
|
||||
|
||||
STRCPY(buf + len, path_end);
|
||||
vim_snprintf(buf + len, buflen - len, "%s", path_end);
|
||||
if (path_has_exp_wildcard(path_end)) { // handle more wildcards
|
||||
// need to expand another component of the path
|
||||
// remove backslashes for the remaining components only
|
||||
|
Reference in New Issue
Block a user