Problem: Another case of buffer overflow with 'helpfile'.
Solution: Leave room for "tags" in the buffer (zeertzjq).
closes: #19340
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
-*version9.txt* For Vim version 9.1. Last change: 2026 Feb 04
+*version9.txt* For Vim version 9.1. Last change: 2026 Feb 06
VIM REFERENCE MANUAL by Bram Moolenaar
using strcpy without bound checks (Rahul Hoysala)
Solution: Limit strncpy to the length of the buffer (MAXPATHL)
+Patch 9.1.2133
+Problem: Another case of buffer overflow with 'helpfile'.
+Solution: Leave room for "tags" in the buffer (zeertzjq).
+
vim:tw=78:ts=8:noet:ft=help:norl:fdm=manual:nofoldenable
if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL)
return FAIL;
++tnp->tn_hf_idx;
- vim_strncpy(buf, p_hf, MAXPATHL - 1);
+ vim_strncpy(buf, p_hf, MAXPATHL - STRLEN_LITERAL("tags") - 1);
STRCPY(gettail(buf), "tags");
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(buf);
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2133,
/**/
2132,
/**/