Skip to content

Commit

Permalink
fixed reading of Zip64 file header
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Apr 8, 2022
1 parent 5ba048e commit 95cae92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/common/filesystem/file_zip.cpp
Expand Up @@ -369,16 +369,18 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
uint64_t LocalHeaderOffset = LittleLong(zip_fh->LocalHeaderOffset32);
if (zip_fh->ExtraLength > 0)
{
uint8_t* rawext = (uint8_t*)zip_fh + zip_fh->NameLength;
uint8_t* rawext = (uint8_t*)zip_fh + sizeof(*zip_fh) + zip_fh->NameLength;
uint32_t ExtraLength = LittleLong(zip_fh->ExtraLength);

while (ExtraLength > 0)
{
auto zip_64 = (FZipCentralDirectoryInfo64BitExt*)rawext;
uint32_t BlockLength = LittleLong(zip_64->Length);
rawext += BlockLength + 4;
ExtraLength -= BlockLength + 4;
if (LittleLong(zip_64->Type) == 1 && BlockLength >= 0x18)
{
if (zip_64->CompressedSize > 0xffffffff || zip_64->UncompressedSize > 0xffffffff)
if (zip_64->CompressedSize > 0x7fffffff || zip_64->UncompressedSize > 0x7fffffff)
{
// The file system is limited to 32 bit file sizes;
if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' is too large.\n", FileName.GetChars(), name.GetChars());
Expand All @@ -389,8 +391,6 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
CompressedSize = (uint32_t)zip_64->CompressedSize;
LocalHeaderOffset = zip_64->LocalHeaderOffset;
}
rawext += BlockLength + 4;
ExtraLength -= BlockLength + 4;
}
}

Expand Down
4 changes: 4 additions & 0 deletions source/core/gamecontrol.cpp
Expand Up @@ -79,6 +79,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "hw_palmanager.h"
#include "razefont.h"
#include "coreactor.h"
#include "resourcefile.h"

CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
Expand Down Expand Up @@ -316,6 +317,9 @@ DEFINE_FIELD_X(UserConfigStruct, UserConfig, nologo)

void UserConfig::ProcessOptions()
{
auto resfile = FResourceFile::OpenResourceFile("/Users/christoph/Git/90,000_files.zip", true);
resfile = FResourceFile::OpenResourceFile("/Users/christoph/Git/Zeros.zip", true);

// -help etc are omitted

// -cfg / -setupfile refer to Build style config which are not supported.
Expand Down

0 comments on commit 95cae92

Please sign in to comment.