Progress?

Get all IO outputs used for possible errors.
Attempt to fix errors from travis-ci.

Signed-off-by: Nev3r <apophycens@gmail.com>
This commit is contained in:
Nev3r 2018-11-25 11:11:50 +01:00
parent 7c44054aa3
commit 32a9e40baa
2 changed files with 28 additions and 3 deletions

View file

@ -540,7 +540,11 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
} }
fseek(handle, -4, SEEK_CUR); fseek(handle, -4, SEEK_CUR);
fread(&zend, 1, sizeof zend, handle); if (fread(&zend, 1, sizeof zend, handle) < sizeof zend)
{
CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", strerror(ferror(handle)));
return NULL;
}
numlumps = zend.entries; numlumps = zend.entries;
lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL); lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL);
@ -553,7 +557,13 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
char* trimname; char* trimname;
char* dotpos; char* dotpos;
fread(zentry, 1, sizeof(zentry_t), handle); if (fread(zentry, 1, sizeof(zentry_t), handle) < sizeof(zentry_t))
{
CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", strerror(ferror(handle)));
Z_Free(lumpinfo);
free(zentry);
return NULL;
}
if (memcmp(zentry->signature, pat_central, 4)) if (memcmp(zentry->signature, pat_central, 4))
{ {
CONS_Alert(CONS_ERROR, "Central directory is corrupt\n"); CONS_Alert(CONS_ERROR, "Central directory is corrupt\n");
@ -567,7 +577,14 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
lump_p->size = zentry->size; lump_p->size = zentry->size;
fullname = malloc(zentry->namelen + 1); fullname = malloc(zentry->namelen + 1);
fgets(fullname, zentry->namelen + 1, handle); if (fgets(fullname, zentry->namelen + 1, handle) != fullname)
{
CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", strerror(ferror(handle)));
Z_Free(lumpinfo);
free(zentry);
free(fullname);
return NULL;
}
// Strip away file address and extension for the 8char name. // Strip away file address and extension for the 8char name.
if ((trimname = strrchr(fullname, '/')) != 0) if ((trimname = strrchr(fullname, '/')) != 0)
@ -591,9 +608,11 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
case 0: case 0:
lump_p->compression = CM_NOCOMPRESSION; lump_p->compression = CM_NOCOMPRESSION;
break; break;
#ifdef HAVE_ZLIB
case 8: case 8:
lump_p->compression = CM_DEFLATE; lump_p->compression = CM_DEFLATE;
break; break;
#endif
case 14: case 14:
lump_p->compression = CM_LZF; lump_p->compression = CM_LZF;
break; break;
@ -1114,6 +1133,7 @@ boolean W_IsLumpWad(lumpnum_t lumpnum)
return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned
} }
#ifdef HAVE_ZLIB
/* report a zlib or i/o error */ /* report a zlib or i/o error */
void zerr(int ret) void zerr(int ret)
{ {
@ -1138,6 +1158,7 @@ void zerr(int ret)
CONS_Printf("zlib version mismatch!\n"); CONS_Printf("zlib version mismatch!\n");
} }
} }
#endif
/** Reads bytes from the head of a lump. /** Reads bytes from the head of a lump.
* Note: If the lump is compressed, the whole thing has to be read anyway. * Note: If the lump is compressed, the whole thing has to be read anyway.
@ -1218,6 +1239,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
Z_Free(decData); Z_Free(decData);
return size; return size;
} }
#ifdef HAVE_ZLIB
case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support. case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support.
{ {
z_const Bytef *rawData; // The lump's raw data. z_const Bytef *rawData; // The lump's raw data.
@ -1271,6 +1293,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
return size; return size;
} }
#endif
default: default:
I_Error("wad %d, lump %d: unsupported compression type!", wad, lump); I_Error("wad %d, lump %d: unsupported compression type!", wad, lump);
} }

View file

@ -47,7 +47,9 @@ typedef struct
typedef enum typedef enum
{ {
CM_NOCOMPRESSION, CM_NOCOMPRESSION,
#ifdef HAVE_ZLIB
CM_DEFLATE, CM_DEFLATE,
#endif
CM_LZF, CM_LZF,
CM_UNSUPPORTED CM_UNSUPPORTED
} compmethod; } compmethod;