mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 17:22:12 +00:00
Don't overlap strncpy in WAD file load
This commit is contained in:
parent
bb9b1b3b1f
commit
5f339fc2a9
1 changed files with 9 additions and 3 deletions
12
src/w_wad.c
12
src/w_wad.c
|
@ -149,9 +149,15 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
|
|||
{
|
||||
FILE *handle;
|
||||
|
||||
strncpy(filenamebuf, *filename, MAX_WADPATH);
|
||||
filenamebuf[MAX_WADPATH - 1] = '\0';
|
||||
*filename = filenamebuf;
|
||||
// Officially, strncpy should not have overlapping buffers, since W_VerifyNMUSlumps is called after this, and it
|
||||
// changes filename to point at filenamebuf, it would technically be doing that. I doubt any issue will occur since
|
||||
// they point to the same location, but it's better to be safe and this is a simple change.
|
||||
if (filenamebuf != *filename)
|
||||
{
|
||||
strncpy(filenamebuf, *filename, MAX_WADPATH);
|
||||
filenamebuf[MAX_WADPATH - 1] = '\0';
|
||||
*filename = filenamebuf;
|
||||
}
|
||||
|
||||
// open wad file
|
||||
if ((handle = fopen(*filename, "rb")) == NULL)
|
||||
|
|
Loading…
Reference in a new issue