mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Cleanups.
committer: mfx <mfx> 1036860405 +0000
This commit is contained in:
parent
f91849ec4b
commit
b6c84d19ab
|
@ -150,24 +150,26 @@ static bool is_dlm(InputFile *fi, long coff_offset)
|
||||||
static void handle_allegropak(InputFile *fi, OutputFile *fo)
|
static void handle_allegropak(InputFile *fi, OutputFile *fo)
|
||||||
{
|
{
|
||||||
unsigned char buf[0x4000];
|
unsigned char buf[0x4000];
|
||||||
unsigned pfsize=0, ic;
|
int pfsize = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fi->seek(-8, SEEK_END);
|
fi->seek(-8, SEEK_END);
|
||||||
fi->readx(buf, 8);
|
fi->readx(buf, 8);
|
||||||
if (memcmp(buf, "slh+", 4) != 0)
|
if (memcmp(buf, "slh+", 4) != 0)
|
||||||
return;
|
return;
|
||||||
pfsize = get_be32(buf+4);
|
pfsize = get_be32_signed(buf+4);
|
||||||
fi->seek(-(off_t)pfsize,SEEK_END);
|
if (pfsize <= 8 || pfsize >= fi->st.st_size)
|
||||||
|
return;
|
||||||
|
fi->seek(-pfsize, SEEK_END);
|
||||||
} catch (const IOException&) {
|
} catch (const IOException&) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (pfsize)
|
while (pfsize > 0)
|
||||||
{
|
{
|
||||||
ic = pfsize < sizeof(buf) ? pfsize : sizeof(buf);
|
const int len = UPX_MIN(pfsize, (int)sizeof(buf));
|
||||||
fi->readx(buf,ic);
|
fi->readx(buf, len);
|
||||||
fo->write(buf,ic);
|
fo->write(buf, len);
|
||||||
pfsize -= ic;
|
pfsize -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ void PackTmt::pack(OutputFile *fo)
|
||||||
|
|
||||||
int PackTmt::canUnpack()
|
int PackTmt::canUnpack()
|
||||||
{
|
{
|
||||||
if (!PackTmt::readFileHeader())
|
if (!readFileHeader())
|
||||||
return false;
|
return false;
|
||||||
fi->seek(adam_offset, SEEK_SET);
|
fi->seek(adam_offset, SEEK_SET);
|
||||||
return readPackHeader(512) ? 1 : -1;
|
return readPackHeader(512) ? 1 : -1;
|
||||||
|
|
|
@ -323,7 +323,8 @@ public:
|
||||||
void finish(upx_byte *&p,unsigned &size);
|
void finish(upx_byte *&p,unsigned &size);
|
||||||
};
|
};
|
||||||
|
|
||||||
Reloc::Reloc(upx_byte *s,unsigned si) : start(s), size(si), rel(0)
|
Reloc::Reloc(upx_byte *s,unsigned si) :
|
||||||
|
start(s), size(si), rel(NULL), rel1(NULL)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(reloc) == 8);
|
COMPILE_TIME_ASSERT(sizeof(reloc) == 8);
|
||||||
memset(counts,0,sizeof(counts));
|
memset(counts,0,sizeof(counts));
|
||||||
|
@ -332,7 +333,8 @@ Reloc::Reloc(upx_byte *s,unsigned si) : start(s), size(si), rel(0)
|
||||||
counts[type]++;
|
counts[type]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reloc::Reloc(unsigned rnum) : rel(0)
|
Reloc::Reloc(unsigned rnum) :
|
||||||
|
start(NULL), size(0), rel(NULL), rel1(NULL)
|
||||||
{
|
{
|
||||||
start = new upx_byte[rnum * 4 + 8192];
|
start = new upx_byte[rnum * 4 + 8192];
|
||||||
counts[0] = 0;
|
counts[0] = 0;
|
||||||
|
@ -790,8 +792,8 @@ private:
|
||||||
Export::Export(char *_base) : base(_base), iv(_base)
|
Export::Export(char *_base) : base(_base), iv(_base)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(export_dir_t) == 40);
|
COMPILE_TIME_ASSERT(sizeof(export_dir_t) == 40);
|
||||||
ename = functionptrs = ordinals = 0;
|
ename = functionptrs = ordinals = NULL;
|
||||||
names = 0;
|
names = NULL;
|
||||||
memset(&edir,0,sizeof(edir));
|
memset(&edir,0,sizeof(edir));
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
@ -1090,7 +1092,7 @@ class Resource
|
||||||
void destroy(upx_rnode *urd,unsigned level);
|
void destroy(upx_rnode *urd,unsigned level);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Resource() : root(0) {}
|
Resource() : root(NULL) {}
|
||||||
Resource(const upx_byte *p) {init(p);}
|
Resource(const upx_byte *p) {init(p);}
|
||||||
~Resource() {if (root) destroy (root,0);}
|
~Resource() {if (root) destroy (root,0);}
|
||||||
void init(const upx_byte *);
|
void init(const upx_byte *);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user