diff --git a/src/nvim/tag.c b/src/nvim/tag.c index ee6b0863f3..ce8e75253d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2495,7 +2495,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 8b7f70a7d1..77f893a90f 100644 --- a/test/old/testdir/test_help.vim +++ b/test/old/testdir/test_help.vim @@ -232,4 +232,13 @@ func Test_help_using_visual_match() 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