From: divverent Date: Sat, 7 Feb 2015 21:14:45 +0000 (+0000) Subject: Fix pak loading bugs. X-Git-Tag: xonotic-v0.8.1~29^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=70d44adf2a3c2f9e3801c1b15c21a390e74c9061;p=xonotic%2Fdarkplaces.git Fix pak loading bugs. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12153 d7cf8633-e32d-0410-b094-e92efae38249 --- 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); }