Skip to content

Commit

Permalink
COMPILER WARNINGS: strncpy() => strlcpy()
Browse files Browse the repository at this point in the history
Pointed out by raket & GCC with -Wstringop-truncation
  • Loading branch information
meag committed Aug 22, 2018
1 parent 4d5177e commit 591a4f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cl_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3727,7 +3727,7 @@ static vfsfile_t* CL_Open_Demo_File(char* name, qbool searchpaks, char** fullPat
else if (searchpaks)
{
// Search demo on quake file system, even in paks.
strncpy(fullname, name, MAX_OSPATH);
strlcpy(fullname, name, sizeof(fullname));
file = FS_OpenVFS(name, "rb", FS_ANY);
}

Expand All @@ -3741,7 +3741,7 @@ static vfsfile_t* CL_Open_Demo_File(char* name, qbool searchpaks, char** fullPat
// Check the full system path (Run a demo anywhere on the file system).
if (!file)
{
strncpy(fullname, name, MAX_OSPATH);
strlcpy(fullname, name, sizeof(fullname));
file = FS_OpenVFS(name, "rb", FS_NONE_OS);
}

Expand Down
2 changes: 1 addition & 1 deletion sys_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void
gpath = "";
*apath = '\0';

strncpy(apath, match, sizeof(apath));
strlcpy(apath, match, sizeof(apath));
for (s = apath+strlen(apath)-1; s >= apath; s--)
{
if (*s == '/')
Expand Down
2 changes: 1 addition & 1 deletion vfs_tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int tarOperationIndexFiles(vfsfile_t *in, packfile_t *files) {

if (getheader == HEADER_SHORTNAME)
{
strncpy(fname,buffer.header.name,SHORTNAMESIZE);
strlcpy(fname,buffer.header.name,sizeof(fname));
if (fname[SHORTNAMESIZE-1] != 0)
fname[SHORTNAMESIZE] = 0;
}
Expand Down

0 comments on commit 591a4f0

Please sign in to comment.