vim-patch:9.1.2133: Another case of buffer overflow with 'helpfile' (#37746)

Problem:  Another case of buffer overflow with 'helpfile'.
Solution: Leave room for "tags" in the buffer (zeertzjq).

closes: vim/vim#19340

21d591fb12
(cherry picked from commit 15061d322d)
This commit is contained in:
zeertzjq
2026-02-06 18:29:24 +08:00
committed by github-actions[bot]
parent 818b97173e
commit 03e68ad5d3
2 changed files with 6 additions and 1 deletions

View File

@@ -2495,7 +2495,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
return FAIL;
}
tnp->tn_hf_idx++;
xstrlcpy(buf, p_hf, MAXPATHL);
xstrlcpy(buf, p_hf, MAXPATHL - STRLEN_LITERAL("tags"));
STRCPY(path_tail(buf), "tags");
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(buf);

View File

@@ -238,6 +238,11 @@ func Test_helpfile_overflow()
let &helpfile = repeat('A', 5000)
help
helpclose
for i in range(4089, 4096)
let &helpfile = repeat('A', i) .. '/A'
help
helpclose
endfor
let &helpfile = _helpfile
endfunc