Skip to content
Snippets Groups Projects
Commit 5f339fc2 authored by Sryder's avatar Sryder
Browse files

Don't overlap strncpy in WAD file load

parent bb9b1b3b
No related branches found
No related tags found
1 merge request!501More Memory Shenanigans
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment