From: divverent Date: Sat, 7 Feb 2015 21:14:27 +0000 (+0000) Subject: Reject pk3s with obviously broken central directory. X-Git-Tag: xonotic-v0.8.1~29^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=28b4551e8ccb79d286d636585d5cf060f0d13aa2;p=xonotic%2Fdarkplaces.git Reject pk3s with obviously broken central directory. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12149 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/fs.c b/fs.c index 67d65713..83a00d87 100644 --- a/fs.c +++ b/fs.c @@ -586,6 +586,16 @@ static qboolean PK3_GetEndOfCentralDir (const char *packfile, int packhandle, pk Mem_Free (buffer); + if ( + eocd->cdir_size < 0 || eocd->cdir_size > filesize || + eocd->cdir_offset < 0 || eocd->cdir_offset >= filesize || + eocd->cdir_offset + eocd->cdir_size > filesize + ) + { + // Obviously invalid central directory. + return false; + } + return true; }