[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk: [53] trunk/extractor
Extract files from unusual archive formats
Brought to you by:
someone-guy
From: <som...@us...> - 2008-02-19 20:54:40
|
Revision: 53 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=53&view=rev Author: someone-guy Date: 2008-02-19 12:54:36 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Properly limit number of listed files Modified Paths: -------------- trunk/extractor/bloodrayne.c trunk/extractor/formats.h trunk/extractor/generic.c trunk/extractor/homeworld2.c trunk/extractor/nwn.c trunk/extractor/xtre.c Modified: trunk/extractor/bloodrayne.c =================================================================== --- trunk/extractor/bloodrayne.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/bloodrayne.c 2008-02-19 20:54:36 UTC (rev 53) @@ -27,6 +27,7 @@ int i; fseek(in, 0x58, SEEK_SET); count = read_le32(in); + if (count > MAX_FILES) count = MAX_FILES; fseek(in, 0x108, SEEK_SET); tblpos = read_le32(in); namepos = tblpos + 20 * count; Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/formats.h 2008-02-19 20:54:36 UTC (rev 53) @@ -1,5 +1,8 @@ #ifndef FORMATS_H #define FORMATS_H + +#define MAX_FILES 100000 + //! struct describing a file in the archive typedef struct file_s { char *name; ///< filename Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/generic.c 2008-02-19 20:54:36 UTC (rev 53) @@ -47,7 +47,7 @@ int cnt = 0; file_t *list = calloc(1, sizeof(file_t)); rewind(in); - while (!feof(in) && cnt + 3 < SIZE_MAX / sizeof(file_t)) { + while (!feof(in) && cnt < MAX_FILES) { int i; t = t << 8 | fgetc(in); switch (t) { Modified: trunk/extractor/homeworld2.c =================================================================== --- trunk/extractor/homeworld2.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/homeworld2.c 2008-02-19 20:54:36 UTC (rev 53) @@ -37,6 +37,7 @@ pathcount = read_le16(in); // number of paths tblpos = read_le32(in) + 0xb4; count = read_le16(in); + if (count > MAX_FILES) count = MAX_FILES; namepos = read_le32(in) + 0xb4; pathmap = calloc(count, sizeof(char *)); paths = calloc(pathcount, sizeof(char *)); Modified: trunk/extractor/nwn.c =================================================================== --- trunk/extractor/nwn.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/nwn.c 2008-02-19 20:54:36 UTC (rev 53) @@ -27,6 +27,7 @@ int i; fseek(in, 0x10, SEEK_SET); count = read_le32(in); + if (count > MAX_FILES) count = MAX_FILES; read_le32(in); // offset for module description namepos = read_le32(in); tblpos = read_le32(in); Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/xtre.c 2008-02-19 20:54:36 UTC (rev 53) @@ -30,6 +30,7 @@ tblend = read_le32(in); if (tblend < tblpos) count = 0; else count = (tblend - tblpos) / 8; + if (count > MAX_FILES) count = MAX_FILES; list = calloc(count + 1, sizeof(file_t)); for (i = 0; i < count; i++) { uint32_t sig; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |