diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 7dd4cd39d1..17ca81ed0a 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2500,7 +2500,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf) return FAIL; } tnp->tn_hf_idx++; - STRCPY(buf, p_hf); + xstrlcpy(buf, p_hf, MAXPATHL); STRCPY(path_tail(buf), "tags"); #ifdef BACKSLASH_IN_FILENAME slash_adjust(buf); diff --git a/test/old/testdir/test_help.vim b/test/old/testdir/test_help.vim index e2ae06d486..c9371221d1 100644 --- a/test/old/testdir/test_help.vim +++ b/test/old/testdir/test_help.vim @@ -296,4 +296,13 @@ func Test_help_command_termination() helpclose endfunc +" This caused a buffer overflow +func Test_helpfile_overflow() + let _helpfile = &helpfile + let &helpfile = repeat('A', 5000) + help + helpclose + let &helpfile = _helpfile +endfunc + " vim: shiftwidth=2 sts=2 expandtab