Cleaned up blocksize handling.
committer: mfx <mfx> 973826681 +0000
This commit is contained in:
+3
-8
@@ -200,17 +200,13 @@ void PackLinuxI386elf::packExtent(
|
|||||||
unsigned &total_out
|
unsigned &total_out
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
blocksize = opt->unix.blocksize;
|
|
||||||
if ((off_t)blocksize > x.size)
|
|
||||||
blocksize = x.size;
|
|
||||||
|
|
||||||
fi->seek(x.offset, SEEK_SET);
|
fi->seek(x.offset, SEEK_SET);
|
||||||
for (off_t rest = x.size; 0!=rest; )
|
for (off_t rest = x.size; 0!=rest; )
|
||||||
{
|
{
|
||||||
int l = fi->readx(ibuf, min_off_t(rest, blocksize));
|
int l = fi->readx(ibuf, min_off_t(rest, opt->unix.blocksize));
|
||||||
rest -= l;
|
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
break;
|
break;
|
||||||
|
rest -= l;
|
||||||
|
|
||||||
// Note: compression for a block can fail if the
|
// Note: compression for a block can fail if the
|
||||||
// file is e.g. blocksize + 1 bytes long
|
// file is e.g. blocksize + 1 bytes long
|
||||||
@@ -255,8 +251,7 @@ void PackLinuxI386elf::packExtent(
|
|||||||
void PackLinuxI386elf::pack(OutputFile *fo)
|
void PackLinuxI386elf::pack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
// set options
|
// set options
|
||||||
opt->unix.blocksize = file_size;
|
opt->unix.blocksize = blocksize = file_size;
|
||||||
blocksize = file_size;
|
|
||||||
progid = 0; // not used
|
progid = 0; // not used
|
||||||
|
|
||||||
fi->readx(&ehdri, sizeof(ehdri));
|
fi->readx(&ehdri, sizeof(ehdri));
|
||||||
|
|||||||
+9
-6
@@ -1,4 +1,4 @@
|
|||||||
/* p_lxsep.cpp --
|
/* p_lx_sep.cpp --
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
@@ -40,11 +40,14 @@
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#define SCRIPT_SIZE (opt->unix.SCRIPT_MAX + sizeof(l_info))
|
||||||
|
|
||||||
const upx_byte *PackLinuxI386sep::getLoader() const
|
const upx_byte *PackLinuxI386sep::getLoader() const
|
||||||
{
|
{
|
||||||
static char script[SCRIPT_MAX + sizeof(l_info)];
|
static char script[SCRIPT_SIZE];
|
||||||
|
|
||||||
memset(script, 0, sizeof(script));
|
memset(script, 0, sizeof(script));
|
||||||
char const *name = opt->script_name;
|
char const *name = opt->unix.script_name;
|
||||||
if (0==name) {
|
if (0==name) {
|
||||||
name = "/usr/local/lib/upxX";
|
name = "/usr/local/lib/upxX";
|
||||||
}
|
}
|
||||||
@@ -63,15 +66,15 @@ const upx_byte *PackLinuxI386sep::getLoader() const
|
|||||||
int PackLinuxI386sep::getLoaderSize() const
|
int PackLinuxI386sep::getLoaderSize() const
|
||||||
{
|
{
|
||||||
if (M_IS_NRV2B(opt->method))
|
if (M_IS_NRV2B(opt->method))
|
||||||
return SCRIPT_MAX + sizeof(l_info);
|
return SCRIPT_SIZE;
|
||||||
if (M_IS_NRV2D(opt->method))
|
if (M_IS_NRV2D(opt->method))
|
||||||
return SCRIPT_MAX + sizeof(l_info);
|
return SCRIPT_SIZE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PackLinuxI386sep::getLoaderPrefixSize() const
|
int PackLinuxI386sep::getLoaderPrefixSize() const
|
||||||
{
|
{
|
||||||
return SCRIPT_MAX;
|
return opt->unix.SCRIPT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxI386sep::patchLoader()
|
void PackLinuxI386sep::patchLoader()
|
||||||
|
|||||||
+4
-2
@@ -153,7 +153,8 @@ bool PackLinuxI386sh::getShellName(char *buf)
|
|||||||
char const *const basename = 1+strrchr(buf, '/');
|
char const *const basename = 1+strrchr(buf, '/');
|
||||||
static char const *const shname[] = { // known shells that accept "-c" arg
|
static char const *const shname[] = { // known shells that accept "-c" arg
|
||||||
"sh", "ash", "bsh", "csh", "ksh", "bash", "tcsh", "pdksh",
|
"sh", "ash", "bsh", "csh", "ksh", "bash", "tcsh", "pdksh",
|
||||||
0
|
//"python", // FIXME: does python work ???
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
for (int j=0; 0 != shname[j]; ++j) {
|
for (int j=0; 0 != shname[j]; ++j) {
|
||||||
if (0==strcmp(shname[j], basename)) {
|
if (0==strcmp(shname[j], basename)) {
|
||||||
@@ -170,6 +171,7 @@ bool PackLinuxI386sh::canUnpackFormat(int format) const
|
|||||||
return UPX_F_LINUX_SH_i386==format;
|
return UPX_F_LINUX_SH_i386==format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PackLinuxI386sh::canPack()
|
bool PackLinuxI386sh::canPack()
|
||||||
{
|
{
|
||||||
#if defined(__linux__) //{
|
#if defined(__linux__) //{
|
||||||
@@ -195,7 +197,7 @@ bool PackLinuxI386sh::canPack()
|
|||||||
void PackLinuxI386sh::pack(OutputFile *fo)
|
void PackLinuxI386sh::pack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
#define PAGE_MASK (~0<<12)
|
#define PAGE_MASK (~0<<12)
|
||||||
opt->unix.blocksize = file_size;
|
opt->unix.blocksize = blocksize = file_size;
|
||||||
PackUnix::pack(fo);
|
PackUnix::pack(fo);
|
||||||
|
|
||||||
// update loader
|
// update loader
|
||||||
|
|||||||
Reference in New Issue
Block a user