From 28b4551e8ccb79d286d636585d5cf060f0d13aa2 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 7 Feb 2015 21:14:27 +0000 Subject: [PATCH] Reject pk3s with obviously broken central directory. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12149 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; } -- 2.39.2