]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix pak loading bugs.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Feb 2015 21:14:45 +0000 (21:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Feb 2015 21:14:45 +0000 (21:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12153 d7cf8633-e32d-0410-b094-e92efae38249

fs.c

diff --git a/fs.c b/fs.c
index e961cd1b5ef3d9fbcb32db0cb267f9de38e5e961..c7cc768152f629b5f336d79a051bab4c521b1548 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1007,7 +1007,7 @@ static pack_t *FS_LoadPackPAK (const char *packfile)
 
        numpackfiles = header.dirlen / sizeof(dpackfile_t);
 
-       if (numpackfiles > MAX_FILES_IN_PACK)
+       if (numpackfiles < 0 || numpackfiles > MAX_FILES_IN_PACK)
        {
                Con_Printf ("%s has %i files\n", packfile, numpackfiles);
                close(packhandle);
@@ -1037,6 +1037,9 @@ static pack_t *FS_LoadPackPAK (const char *packfile)
                fs_offset_t offset = (unsigned int)LittleLong (info[i].filepos);
                fs_offset_t size = (unsigned int)LittleLong (info[i].filelen);
 
+               // Ensure a zero terminated file name (required by format).
+               info[i].name[sizeof(info[i].name) - 1] = 0;
+
                FS_AddFileToPack (info[i].name, pack, offset, size, size, PACKFILE_FLAG_TRUEOFFS);
        }