]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
make color averaging use 64bit integers, instead of 32bit ones, as they wrap on 512x5...
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 4d720f3615dea689480a0257c48782de2a0c1b4a..12dfc317ccdb46d6ef591b0101ed2f3281077eb9 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -472,7 +472,11 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd)
        // Load the central directory in memory
        central_dir = (unsigned char *)Mem_Alloc (tempmempool, eocd->cdir_size);
        lseek (pack->handle, eocd->cdir_offset, SEEK_SET);
-       read (pack->handle, central_dir, eocd->cdir_size);
+       if(read (pack->handle, central_dir, eocd->cdir_size) != (ssize_t) eocd->cdir_size)
+       {
+               Mem_Free (central_dir);
+               return -1;
+       }
 
        // Extract the files properties
        // The parsing is done "by hand" because some fields have variable sizes and
@@ -808,7 +812,12 @@ pack_t *FS_LoadPackPAK (const char *packfile)
 #endif
        if (packhandle < 0)
                return NULL;
-       read (packhandle, (void *)&header, sizeof(header));
+       if(read (packhandle, (void *)&header, sizeof(header)) != sizeof(header))
+       {
+               Con_Printf ("%s is not a packfile\n", packfile);
+               close(packhandle);
+               return NULL;
+       }
        if (memcmp(header.id, "PACK", 4))
        {
                Con_Printf ("%s is not a packfile\n", packfile);