Skip to content

Commit 6f833c7

Browse files
committed
Merge pull request neovim#4328 from justinmk/coverity
coverity/71532: STRING_OVERFLOW
2 parents 37d6004 + 9b99cf4 commit 6f833c7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: src/nvim/ex_cmds.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -4877,16 +4877,13 @@ helptags_one (
48774877
int fi;
48784878
char_u *s;
48794879
char_u *fname;
4880-
int dirlen;
48814880
int utf8 = MAYBE;
48824881
int this_utf8;
48834882
int firstline;
48844883
int mix = FALSE; /* detected mixed encodings */
48854884

4886-
/*
4887-
* Find all *.txt files.
4888-
*/
4889-
dirlen = (int)STRLEN(dir);
4885+
// Find all *.txt files.
4886+
size_t dirlen = STRLEN(dir);
48904887
STRCPY(NameBuff, dir);
48914888
STRCAT(NameBuff, "/**/*");
48924889
STRCAT(NameBuff, ext);
@@ -4908,7 +4905,7 @@ helptags_one (
49084905
*/
49094906
STRCPY(NameBuff, dir);
49104907
add_pathsep((char *)NameBuff);
4911-
STRCAT(NameBuff, tagfname);
4908+
STRNCAT(NameBuff, tagfname, sizeof(NameBuff) - dirlen - 2);
49124909
fd_tags = mch_fopen((char *)NameBuff, "w");
49134910
if (fd_tags == NULL) {
49144911
EMSG2(_("E152: Cannot open %s for writing"), NameBuff);

0 commit comments

Comments
 (0)