From 70d44adf2a3c2f9e3801c1b15c21a390e74c9061 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 7 Feb 2015 21:14:45 +0000 Subject: [PATCH] Fix pak loading bugs. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12153 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs.c b/fs.c index e961cd1b..c7cc7681 100644 --- 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); } -- 2.39.2