1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

fixed resource bounds checking when compressing; let --force override throwing an exception

This commit is contained in:
László Molnár 2015-08-11 13:05:10 +02:00
parent 718a1da262
commit 33065ecf04
2 changed files with 10 additions and 6 deletions

View File

@ -1494,8 +1494,12 @@ struct PeFile::Resource::upx_rleaf : public PeFile::Resource::upx_rnode
res_data data;
};
PeFile::Resource::Resource() : root(NULL)
{}
PeFile::Resource::Resource(const upx_byte *ibufstart_,
const upx_byte *ibufend_) : root(NULL)
{
ibufstart = ibufstart_;
ibufend = ibufend_;
}
PeFile::Resource::Resource(const upx_byte *p,
const upx_byte *ibufstart_,
@ -2126,8 +2130,8 @@ unsigned PeFile::readSections(unsigned objs, unsigned usize,
== (PEFL_WRITE|PEFL_SHARED)))
if (!opt->force)
throwCantPack("writable shared sections not supported (try --force)");
if (jc && isection[ic].rawdataptr - jc > ih_filealign)
throwCantPack("superfluous data between sections");
if (jc && isection[ic].rawdataptr - jc > ih_filealign && !opt->force)
throwCantPack("superfluous data between sections (try --force)");
fi->seek(isection[ic].rawdataptr,SEEK_SET);
jc = isection[ic].size;
if (jc > isection[ic].vsize)
@ -2194,7 +2198,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh,
overlay = 0;
checkOverlay(overlay);
Resource res;
Resource res(ibuf, ibuf + ibuf.getSize());
Interval tlsiv(ibuf);
Interval loadconfiv(ibuf);
Export xport((char*)(unsigned char*)ibuf);

View File

@ -353,7 +353,7 @@ protected:
void ibufcheck(const void *m, unsigned size);
public:
Resource();
Resource(const upx_byte *ibufstart, const upx_byte *ibufen);
Resource(const upx_byte *p, const upx_byte *ibufstart,
const upx_byte *ibufend);
~Resource();