From fdd4e1fe83f2af439d0dac84d1ad82f120f99758 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Sun, 15 Apr 2007 23:34:49 +0000 Subject: [PATCH] Correction git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2734 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/doc/devel/pkgformat | 2 +- tools/pkg/unpkg.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sc2/doc/devel/pkgformat b/sc2/doc/devel/pkgformat index 84cdfa61c..5fc150c64 100644 --- a/sc2/doc/devel/pkgformat +++ b/sc2/doc/devel/pkgformat @@ -151,7 +151,7 @@ packmem_list_offs [1]. The length of a packaged file, even with the multiplier, is overflowed for some resources. The actual size is a multiple of 0x10000 times the multiplier larger. -This occurs in 8 packages in the PC version of Star Control II, in +This occurs in 18 packages in the PC version of Star Control II, in 1 packages of the Amiga version of Star Control 1, and in 2 packages of the PC version of The Horde. The PC version of Star Control 1, and the 3DO version of Star Control II don't have such overflows. diff --git a/tools/pkg/unpkg.c b/tools/pkg/unpkg.c index 30e567ca3..bdcf6420e 100644 --- a/tools/pkg/unpkg.c +++ b/tools/pkg/unpkg.c @@ -69,6 +69,7 @@ main(int argc, char *argv[]) { uint8 *buf; index_header *h; struct options opts; + off_t inSize; parse_arguments(argc, argv, &opts); @@ -83,8 +84,9 @@ main(int argc, char *argv[]) { perror("stat() failed"); return EXIT_FAILURE; } + inSize = sb.st_size; - buf = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, in, 0); + buf = mmap(NULL, inSize, PROT_READ, MAP_SHARED, in, 0); if (buf == MAP_FAILED) { perror("mmap() failed"); return EXIT_FAILURE; @@ -103,7 +105,7 @@ main(int argc, char *argv[]) { } { - FilesStats *stats = createFilesStats(h, buf, sb.st_size); + FilesStats *stats = createFilesStats(h, buf, inSize); analyzeFilesStats(&opts, h, stats); } @@ -141,7 +143,7 @@ main(int argc, char *argv[]) { } // freeIndex(h); - munmap(buf, sb.st_size); + munmap(buf, inSize); return EXIT_SUCCESS; } @@ -678,7 +680,7 @@ analyzeFilesStats(struct options *opts, const index_header *h, size_t filesStatsI; int multiplier = resourceSizeMultiplier(opts->type); - for (filesStatsI = 0; filesStatsI < filesStats->indexUpper - 1; + for (filesStatsI = 0; filesStatsI < filesStats->indexUpper; filesStatsI++) { FileStats *stats = &filesStats->fileStats[filesStatsI]; size_t packI;