mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
-Fixes in new resource file code: Added file length checks and set lump count to 1 for single lump files.
SVN r1558 (trunk)
This commit is contained in:
parent
1ea8777572
commit
2e90519c13
7 changed files with 61 additions and 42 deletions
|
@ -334,14 +334,17 @@ FResourceFile *Check7Z(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[k7zSignatureSize];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, k7zSignatureSize);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, k7zSignature, k7zSignatureSize))
|
||||
if (file->GetLength() >= k7zSignatureSize)
|
||||
{
|
||||
FResourceFile *rf = new F7ZFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, k7zSignatureSize);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, k7zSignature, k7zSignatureSize))
|
||||
{
|
||||
FResourceFile *rf = new F7ZFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -138,14 +138,17 @@ FResourceFile *CheckGRP(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[12];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 12);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "KenSilverman", 12))
|
||||
if (file->GetLength() >= 12)
|
||||
{
|
||||
FResourceFile *rf = new FGrpFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 12);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "KenSilverman", 12))
|
||||
{
|
||||
FResourceFile *rf = new FGrpFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ bool FLumpFile::Open()
|
|||
Lumps->Namespace = ns_global;
|
||||
Lumps->Flags = 0;
|
||||
Lumps->FullName = NULL;
|
||||
NumLumps = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,14 +130,17 @@ FResourceFile *CheckPak(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[4];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "PACK", 4))
|
||||
if (file->GetLength() >= 12)
|
||||
{
|
||||
FResourceFile *rf = new FPakFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "PACK", 4))
|
||||
{
|
||||
FResourceFile *rf = new FPakFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -235,14 +235,17 @@ FResourceFile *CheckRFF(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[4];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "RFF\x1a", 4))
|
||||
if (file->GetLength() >= 16)
|
||||
{
|
||||
FResourceFile *rf = new FRFFFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "RFF\x1a", 4))
|
||||
{
|
||||
FResourceFile *rf = new FRFFFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -328,14 +328,17 @@ FResourceFile *CheckWad(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[4];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "IWAD", 4) || !memcmp(head, "PWAD", 4))
|
||||
if (file->GetLength() >= 12)
|
||||
{
|
||||
FResourceFile *rf = new FWadFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "IWAD", 4) || !memcmp(head, "PWAD", 4))
|
||||
{
|
||||
FResourceFile *rf = new FWadFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -391,14 +391,17 @@ FResourceFile *CheckZip(const char *filename, FileReader *file)
|
|||
{
|
||||
char head[4];
|
||||
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "PK\x3\x4", 4))
|
||||
if (file->GetLength() >= sizeof(FZipLocalFileHeader))
|
||||
{
|
||||
FResourceFile *rf = new FZipFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
file->Seek(0, SEEK_SET);
|
||||
file->Read(&head, 4);
|
||||
file->Seek(0, SEEK_SET);
|
||||
if (!memcmp(head, "PK\x3\x4", 4))
|
||||
{
|
||||
FResourceFile *rf = new FZipFile(filename, file);
|
||||
if (rf->Open()) return rf;
|
||||
delete rf;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue