committer: mfx <mfx> 1042576530 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2003-01-14 20:35:30 +00:00
parent a709b38065
commit 29c1f67057
+9 -5
View File
@@ -136,6 +136,8 @@ int PackTos::getLoaderSize() const
/*************************************************************************
// util
// readFileHeader() reads ih and checks for illegal values
// checkFileHeader() checks ih for legal but unsupported values
**************************************************************************/
int PackTos::readFileHeader()
@@ -365,14 +367,15 @@ bool PackTos::canPack()
if (!readFileHeader())
return false;
unsigned char buf[512];
unsigned char buf[768];
fi->readx(buf, sizeof(buf));
checkAlreadyPacked(buf, sizeof(buf));
if (!checkFileHeader())
throwCantPack("unsupported header flags");
if (file_size < 256)
throwCantPack("program too small");
if (file_size < 1024)
throwCantPack("program is too small");
return true;
}
@@ -474,8 +477,8 @@ void PackTos::pack(OutputFile *fo)
// After compression this will become the first part of the
// data segement. The second part will be the decompressor.
// alloc buffer
obuf.allocForCompression(t + d_len + 512);
// alloc buffer (512 is for the various alignments)
obuf.allocForCompression(t, d_len + 512);
// prepare packheader
ph.u_len = t;
@@ -635,6 +638,7 @@ int PackTos::canUnpack()
if ((ih.fh_text & 3) != 0 || (ih.fh_data & 3) != 0 || (ih.fh_bss & 3) != 0
|| ih.fh_sym != 0 || ih.fh_reserved != 0 || ih.fh_reloc > 1)
throwCantUnpack("program header damaged");
// generic check
if (!checkFileHeader())
throwCantUnpack("unsupported header flags");
return true;