mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-07 09:01:57 +00:00
- Remove 255 character length restriction on lump names.
- Removed directory checking for big endian wads since the header check should be sufficient. SVN r3899 (trunk)
This commit is contained in:
parent
4b218c1c18
commit
cd2c1f6816
4 changed files with 28 additions and 63 deletions
|
@ -271,7 +271,6 @@ bool F7ZFile::Open(bool quiet)
|
||||||
for (DWORD i = 0; i < NumLumps; ++i)
|
for (DWORD i = 0; i < NumLumps; ++i)
|
||||||
{
|
{
|
||||||
CSzFileItem *file = &Archive->DB.db.Files[i];
|
CSzFileItem *file = &Archive->DB.db.Files[i];
|
||||||
char name[256];
|
|
||||||
|
|
||||||
// skip Directories
|
// skip Directories
|
||||||
if (file->IsDir)
|
if (file->IsDir)
|
||||||
|
@ -280,10 +279,9 @@ bool F7ZFile::Open(bool quiet)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(name, file->Name, countof(name)-1);
|
FString name = file->Name;
|
||||||
name[countof(name)-1] = 0;
|
|
||||||
FixPathSeperator(name);
|
FixPathSeperator(name);
|
||||||
strlwr(name);
|
name.ToLower();
|
||||||
|
|
||||||
lump_p->LumpNameSetup(name);
|
lump_p->LumpNameSetup(name);
|
||||||
lump_p->LumpSize = int(file->Size);
|
lump_p->LumpSize = int(file->Size);
|
||||||
|
|
|
@ -336,7 +336,7 @@ bool FWadFile::Open(bool quiet)
|
||||||
InfoTableOfs = LittleLong(header.InfoTableOfs);
|
InfoTableOfs = LittleLong(header.InfoTableOfs);
|
||||||
|
|
||||||
// Check to see if the little endian interpretation is valid
|
// Check to see if the little endian interpretation is valid
|
||||||
// This should detect most big endian wads
|
// This should be sufficient to detect big endian wads.
|
||||||
if (InfoTableOfs + NumLumps*sizeof(wadlump_t) > (unsigned)wadSize)
|
if (InfoTableOfs + NumLumps*sizeof(wadlump_t) > (unsigned)wadSize)
|
||||||
{
|
{
|
||||||
NumLumps = BigLong(header.NumLumps);
|
NumLumps = BigLong(header.NumLumps);
|
||||||
|
@ -344,53 +344,28 @@ bool FWadFile::Open(bool quiet)
|
||||||
isBigEndian = true;
|
isBigEndian = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the directory. If we're still assuming little endian and the lump
|
wadlump_t *fileinfo = new wadlump_t[NumLumps];
|
||||||
// is out of range then we switch to big endian mode and try again.
|
Reader->Seek (InfoTableOfs, SEEK_SET);
|
||||||
do
|
Reader->Read (fileinfo, NumLumps * sizeof(wadlump_t));
|
||||||
|
|
||||||
|
Lumps = new FWadFileLump[NumLumps];
|
||||||
|
|
||||||
|
for(DWORD i = 0; i < NumLumps; i++)
|
||||||
{
|
{
|
||||||
wadlump_t *fileinfo = new wadlump_t[NumLumps];
|
uppercopy (Lumps[i].Name, fileinfo[i].Name);
|
||||||
Reader->Seek (InfoTableOfs, SEEK_SET);
|
Lumps[i].Name[8] = 0;
|
||||||
Reader->Read (fileinfo, NumLumps * sizeof(wadlump_t));
|
Lumps[i].Compressed = Lumps[i].Name[0] & 0x80;
|
||||||
|
Lumps[i].Name[0] &= ~0x80;
|
||||||
|
|
||||||
Lumps = new FWadFileLump[NumLumps];
|
Lumps[i].Owner = this;
|
||||||
|
Lumps[i].Position = isBigEndian ? BigLong(fileinfo[i].FilePos) : LittleLong(fileinfo[i].FilePos);
|
||||||
bool valid = true;
|
Lumps[i].LumpSize = isBigEndian ? BigLong(fileinfo[i].Size) : LittleLong(fileinfo[i].Size);
|
||||||
for(DWORD i = 0; i < NumLumps; i++)
|
Lumps[i].Namespace = ns_global;
|
||||||
{
|
Lumps[i].Flags = 0;
|
||||||
uppercopy (Lumps[i].Name, fileinfo[i].Name);
|
Lumps[i].FullName = NULL;
|
||||||
Lumps[i].Name[8] = 0;
|
|
||||||
Lumps[i].Compressed = Lumps[i].Name[0] & 0x80;
|
|
||||||
Lumps[i].Name[0] &= ~0x80;
|
|
||||||
|
|
||||||
Lumps[i].Owner = this;
|
|
||||||
Lumps[i].Position = isBigEndian ? BigLong(fileinfo[i].FilePos) : LittleLong(fileinfo[i].FilePos);
|
|
||||||
Lumps[i].LumpSize = isBigEndian ? BigLong(fileinfo[i].Size) : LittleLong(fileinfo[i].Size);
|
|
||||||
if(Lumps[i].Position > wadSize || Lumps[i].Position + Lumps[i].LumpSize > wadSize)
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Lumps[i].Namespace = ns_global;
|
|
||||||
Lumps[i].Flags = 0;
|
|
||||||
Lumps[i].FullName = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] fileinfo;
|
|
||||||
if(!valid)
|
|
||||||
{
|
|
||||||
if(isBigEndian)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
delete[] Lumps;
|
|
||||||
NumLumps = BigLong(header.NumLumps);
|
|
||||||
InfoTableOfs = BigLong(header.InfoTableOfs);
|
|
||||||
isBigEndian = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
while(true);
|
|
||||||
|
delete[] fileinfo;
|
||||||
|
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,11 +210,8 @@ bool FZipFile::Open(bool quiet)
|
||||||
{
|
{
|
||||||
FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr;
|
FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr;
|
||||||
|
|
||||||
char name[256];
|
|
||||||
|
|
||||||
int len = LittleShort(zip_fh->NameLength);
|
int len = LittleShort(zip_fh->NameLength);
|
||||||
strncpy(name, dirptr + sizeof(FZipCentralDirectoryInfo), MIN<int>(len, 255));
|
FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len);
|
||||||
name[len] = 0;
|
|
||||||
dirptr += sizeof(FZipCentralDirectoryInfo) +
|
dirptr += sizeof(FZipCentralDirectoryInfo) +
|
||||||
LittleShort(zip_fh->NameLength) +
|
LittleShort(zip_fh->NameLength) +
|
||||||
LittleShort(zip_fh->ExtraLength) +
|
LittleShort(zip_fh->ExtraLength) +
|
||||||
|
@ -236,7 +233,7 @@ bool FZipFile::Open(bool quiet)
|
||||||
zip_fh->Method != METHOD_IMPLODE &&
|
zip_fh->Method != METHOD_IMPLODE &&
|
||||||
zip_fh->Method != METHOD_SHRINK)
|
zip_fh->Method != METHOD_SHRINK)
|
||||||
{
|
{
|
||||||
if (!quiet) Printf("\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name, zip_fh->Method);
|
if (!quiet) Printf("\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name.GetChars(), zip_fh->Method);
|
||||||
skipped++;
|
skipped++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -244,13 +241,13 @@ bool FZipFile::Open(bool quiet)
|
||||||
zip_fh->Flags = LittleShort(zip_fh->Flags);
|
zip_fh->Flags = LittleShort(zip_fh->Flags);
|
||||||
if (zip_fh->Flags & ZF_ENCRYPTED)
|
if (zip_fh->Flags & ZF_ENCRYPTED)
|
||||||
{
|
{
|
||||||
if (!quiet) Printf("\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name);
|
if (!quiet) Printf("\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name.GetChars());
|
||||||
skipped++;
|
skipped++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FixPathSeperator(name);
|
FixPathSeperator(name);
|
||||||
strlwr(name);
|
name.ToLower();
|
||||||
|
|
||||||
lump_p->LumpNameSetup(name);
|
lump_p->LumpNameSetup(name);
|
||||||
lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize);
|
lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize);
|
||||||
|
|
|
@ -96,15 +96,10 @@ FResourceLump::~FResourceLump()
|
||||||
|
|
||||||
void FResourceLump::LumpNameSetup(const char *iname)
|
void FResourceLump::LumpNameSetup(const char *iname)
|
||||||
{
|
{
|
||||||
char base[256];
|
|
||||||
const char *lname = strrchr(iname,'/');
|
const char *lname = strrchr(iname,'/');
|
||||||
lname = (lname == NULL) ? iname : lname + 1;
|
lname = (lname == NULL) ? iname : lname + 1;
|
||||||
strcpy(base, lname);
|
FString base = lname;
|
||||||
char *dot = strrchr(base, '.');
|
base = base.Left(base.LastIndexOf('.'));
|
||||||
if (dot != NULL)
|
|
||||||
{
|
|
||||||
*dot = 0;
|
|
||||||
}
|
|
||||||
uppercopy(Name, base);
|
uppercopy(Name, base);
|
||||||
Name[8] = 0;
|
Name[8] = 0;
|
||||||
FullName = copystring(iname);
|
FullName = copystring(iname);
|
||||||
|
|
Loading…
Reference in a new issue