coverity/150263: s/STRCPY/STRLCPY/, bounds check (#5036)

This commit is contained in:
J Phani Mahesh
2016-07-20 11:05:44 +05:30
committed by Justin M. Keyes
parent 77937c4edd
commit 92866042d9

View File

@@ -4821,9 +4821,8 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
int mix = FALSE; /* detected mixed encodings */ int mix = FALSE; /* detected mixed encodings */
// Find all *.txt files. // Find all *.txt files.
size_t dirlen = STRLEN(dir); size_t dirlen = STRLCPY(NameBuff, dir, sizeof(NameBuff));
STRCPY(NameBuff, dir); STRCAT(NameBuff, "/**/*"); // NOLINT
STRCAT(NameBuff, "/**/*");
STRCAT(NameBuff, ext); STRCAT(NameBuff, ext);
// Note: We cannot just do `&NameBuff` because it is a statically sized array // Note: We cannot just do `&NameBuff` because it is a statically sized array
@@ -4841,7 +4840,7 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
* Open the tags file for writing. * Open the tags file for writing.
* Do this before scanning through all the files. * Do this before scanning through all the files.
*/ */
STRCPY(NameBuff, dir); STRLCPY(NameBuff, dir, sizeof(NameBuff));
add_pathsep((char *)NameBuff); add_pathsep((char *)NameBuff);
STRNCAT(NameBuff, tagfname, sizeof(NameBuff) - dirlen - 2); STRNCAT(NameBuff, tagfname, sizeof(NameBuff) - dirlen - 2);
fd_tags = mch_fopen((char *)NameBuff, "w"); fd_tags = mch_fopen((char *)NameBuff, "w");
@@ -5016,7 +5015,7 @@ static void do_helptags(char_u *dirname, bool add_help_tags)
char_u **files; char_u **files;
// Get a list of all files in the help directory and in subdirectories. // Get a list of all files in the help directory and in subdirectories.
STRCPY(NameBuff, dirname); STRLCPY(NameBuff, dirname, sizeof(NameBuff));
add_pathsep((char *)NameBuff); add_pathsep((char *)NameBuff);
STRCAT(NameBuff, "**"); STRCAT(NameBuff, "**");