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 // util
// readFileHeader() reads ih and checks for illegal values
// checkFileHeader() checks ih for legal but unsupported values
**************************************************************************/ **************************************************************************/
int PackTos::readFileHeader() int PackTos::readFileHeader()
@@ -365,14 +367,15 @@ bool PackTos::canPack()
if (!readFileHeader()) if (!readFileHeader())
return false; return false;
unsigned char buf[512]; unsigned char buf[768];
fi->readx(buf, sizeof(buf)); fi->readx(buf, sizeof(buf));
checkAlreadyPacked(buf, sizeof(buf)); checkAlreadyPacked(buf, sizeof(buf));
if (!checkFileHeader()) if (!checkFileHeader())
throwCantPack("unsupported header flags"); throwCantPack("unsupported header flags");
if (file_size < 256) if (file_size < 1024)
throwCantPack("program too small"); throwCantPack("program is too small");
return true; return true;
} }
@@ -474,8 +477,8 @@ void PackTos::pack(OutputFile *fo)
// After compression this will become the first part of the // After compression this will become the first part of the
// data segement. The second part will be the decompressor. // data segement. The second part will be the decompressor.
// alloc buffer // alloc buffer (512 is for the various alignments)
obuf.allocForCompression(t + d_len + 512); obuf.allocForCompression(t, d_len + 512);
// prepare packheader // prepare packheader
ph.u_len = t; 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 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) || ih.fh_sym != 0 || ih.fh_reserved != 0 || ih.fh_reloc > 1)
throwCantUnpack("program header damaged"); throwCantUnpack("program header damaged");
// generic check
if (!checkFileHeader()) if (!checkFileHeader())
throwCantUnpack("unsupported header flags"); throwCantUnpack("unsupported header flags");
return true; return true;