Added Packer::getLoaderSectionStart(), where the size of the section
is allowed to be zero. committer: mfx <mfx> 976719893 +0000
This commit is contained in:
+1
-1
@@ -156,7 +156,7 @@ void PackvmlinuzI386::pack(OutputFile *fo)
|
|||||||
MemBuffer loader(lsize);
|
MemBuffer loader(lsize);
|
||||||
memcpy(loader, getLoader(), lsize);
|
memcpy(loader, getLoader(), lsize);
|
||||||
|
|
||||||
int e_len = bzImage ? getLoaderSection("LZCUTPOI") : lsize;
|
int e_len = bzImage ? getLoaderSectionStart("LZCUTPOI") : lsize;
|
||||||
patchPackHeader(loader, lsize);
|
patchPackHeader(loader, lsize);
|
||||||
|
|
||||||
if (bzImage)
|
if (bzImage)
|
||||||
|
|||||||
+23
-6
@@ -42,7 +42,7 @@
|
|||||||
Packer::Packer(InputFile *f) :
|
Packer::Packer(InputFile *f) :
|
||||||
fi(f), file_size(-1), ph_format(-1), ph_version(-1),
|
fi(f), file_size(-1), ph_format(-1), ph_version(-1),
|
||||||
uip(NULL), ui_pass(0), ui_total_passes(0), linker(NULL),
|
uip(NULL), ui_pass(0), ui_total_passes(0), linker(NULL),
|
||||||
last_patch(NULL), last_patch_offset(0)
|
last_patch(NULL), last_patch_len(0), last_patch_off(0)
|
||||||
{
|
{
|
||||||
file_size = f->st.st_size;
|
file_size = f->st.st_size;
|
||||||
uip = new UiPacker(this);
|
uip = new UiPacker(this);
|
||||||
@@ -642,22 +642,28 @@ void Packer::checkPatch(void *b, int blen, int boff, int size)
|
|||||||
{
|
{
|
||||||
// reset
|
// reset
|
||||||
last_patch = NULL;
|
last_patch = NULL;
|
||||||
last_patch_offset = 0;
|
last_patch_len = 0;
|
||||||
|
last_patch_off = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (b == NULL || blen <= 0 || boff < 0 || size <= 0)
|
if (b == NULL || blen <= 0 || boff < 0 || size <= 0)
|
||||||
throwBadLoader();
|
throwBadLoader();
|
||||||
if (boff + size <= 0 || boff + size > blen)
|
if (boff + size <= 0 || boff + size > blen)
|
||||||
throwBadLoader();
|
throwBadLoader();
|
||||||
//printf("checkPatch: %p %5d %5d %d\n", b, blen, boff, size);
|
//printf("checkPatch: %p %5d %5d %2d\n", b, blen, boff, size);
|
||||||
if (b == last_patch)
|
if (b == last_patch)
|
||||||
{
|
{
|
||||||
if (boff + size > last_patch_offset)
|
if (boff + size > last_patch_off)
|
||||||
throwInternalError("invalid patch order");
|
throwInternalError("invalid patch order");
|
||||||
|
// The next check is not strictly necessary, but the buffer
|
||||||
|
// length should better not increase...
|
||||||
|
if (blen > last_patch_len)
|
||||||
|
throwInternalError("invalid patch order (length)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
last_patch = b;
|
last_patch = b;
|
||||||
last_patch_offset = boff;
|
last_patch_len = blen;
|
||||||
|
last_patch_off = boff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -916,7 +922,7 @@ void Packer::addSection(const char *sname, const char *sdata, unsigned len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Packer::getLoaderSection(const char *name, int *slen)
|
int Packer::getLoaderSection(const char *name, int *slen) const
|
||||||
{
|
{
|
||||||
int size = -1;
|
int size = -1;
|
||||||
int ostart = linker->getSection(name, &size);
|
int ostart = linker->getSection(name, &size);
|
||||||
@@ -928,6 +934,17 @@ int Packer::getLoaderSection(const char *name, int *slen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// same, but the size of the section may be == 0
|
||||||
|
int Packer::getLoaderSectionStart(const char *name) const
|
||||||
|
{
|
||||||
|
int size = -1;
|
||||||
|
int ostart = linker->getSection(name, &size);
|
||||||
|
if (ostart < 0 || size < 0)
|
||||||
|
throwBadLoader();
|
||||||
|
return ostart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const upx_byte *Packer::getLoader() const
|
const upx_byte *Packer::getLoader() const
|
||||||
{
|
{
|
||||||
int size = -1;
|
int size = -1;
|
||||||
|
|||||||
+4
-2
@@ -199,7 +199,8 @@ protected:
|
|||||||
virtual void initLoader(const void *pdata, int plen, int pinfo=-1);
|
virtual void initLoader(const void *pdata, int plen, int pinfo=-1);
|
||||||
virtual void addLoader(const char *s, ...);
|
virtual void addLoader(const char *s, ...);
|
||||||
virtual void addSection(const char *sname, const char *sdata, unsigned len);
|
virtual void addSection(const char *sname, const char *sdata, unsigned len);
|
||||||
virtual int getLoaderSection(const char *name, int *slen = NULL);
|
virtual int getLoaderSection(const char *name, int *slen=NULL) const;
|
||||||
|
virtual int getLoaderSectionStart(const char *name) const;
|
||||||
virtual void addFilter32(int filter_id);
|
virtual void addFilter32(int filter_id);
|
||||||
virtual const char *getDecompressor() const;
|
virtual const char *getDecompressor() const;
|
||||||
|
|
||||||
@@ -253,7 +254,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
// private to checkPatch()
|
// private to checkPatch()
|
||||||
void *last_patch;
|
void *last_patch;
|
||||||
int last_patch_offset;
|
int last_patch_len;
|
||||||
|
int last_patch_off;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disable copy and assignment
|
// disable copy and assignment
|
||||||
|
|||||||
Reference in New Issue
Block a user