Cleaned up blocksize handling.

committer: mfx <mfx> 973826681 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2000-11-10 03:24:41 +00:00
parent 079d735c1d
commit 31c91fbc0e
3 changed files with 16 additions and 16 deletions

View File

@ -200,17 +200,13 @@ void PackLinuxI386elf::packExtent(
unsigned &total_out
)
{
blocksize = opt->unix.blocksize;
if ((off_t)blocksize > x.size)
blocksize = x.size;
fi->seek(x.offset, SEEK_SET);
for (off_t rest = x.size; 0!=rest; )
{
int l = fi->readx(ibuf, min_off_t(rest, blocksize));
rest -= l;
int l = fi->readx(ibuf, min_off_t(rest, opt->unix.blocksize));
if (l == 0)
break;
rest -= l;
// Note: compression for a block can fail if the
// file is e.g. blocksize + 1 bytes long
@ -255,8 +251,7 @@ void PackLinuxI386elf::packExtent(
void PackLinuxI386elf::pack(OutputFile *fo)
{
// set options
opt->unix.blocksize = file_size;
blocksize = file_size;
opt->unix.blocksize = blocksize = file_size;
progid = 0; // not used
fi->readx(&ehdri, sizeof(ehdri));

View File

@ -1,4 +1,4 @@
/* p_lxsep.cpp --
/* p_lx_sep.cpp --
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
{
static char script[SCRIPT_MAX + sizeof(l_info)];
static char script[SCRIPT_SIZE];
memset(script, 0, sizeof(script));
char const *name = opt->script_name;
char const *name = opt->unix.script_name;
if (0==name) {
name = "/usr/local/lib/upxX";
}
@ -63,15 +66,15 @@ const upx_byte *PackLinuxI386sep::getLoader() const
int PackLinuxI386sep::getLoaderSize() const
{
if (M_IS_NRV2B(opt->method))
return SCRIPT_MAX + sizeof(l_info);
return SCRIPT_SIZE;
if (M_IS_NRV2D(opt->method))
return SCRIPT_MAX + sizeof(l_info);
return SCRIPT_SIZE;
return 0;
}
int PackLinuxI386sep::getLoaderPrefixSize() const
{
return SCRIPT_MAX;
return opt->unix.SCRIPT_MAX;
}
void PackLinuxI386sep::patchLoader()

View File

@ -153,7 +153,8 @@ bool PackLinuxI386sh::getShellName(char *buf)
char const *const basename = 1+strrchr(buf, '/');
static char const *const shname[] = { // known shells that accept "-c" arg
"sh", "ash", "bsh", "csh", "ksh", "bash", "tcsh", "pdksh",
0
//"python", // FIXME: does python work ???
NULL
};
for (int j=0; 0 != shname[j]; ++j) {
if (0==strcmp(shname[j], basename)) {
@ -170,6 +171,7 @@ bool PackLinuxI386sh::canUnpackFormat(int format) const
return UPX_F_LINUX_SH_i386==format;
}
bool PackLinuxI386sh::canPack()
{
#if defined(__linux__) //{
@ -195,7 +197,7 @@ bool PackLinuxI386sh::canPack()
void PackLinuxI386sh::pack(OutputFile *fo)
{
#define PAGE_MASK (~0<<12)
opt->unix.blocksize = file_size;
opt->unix.blocksize = blocksize = file_size;
PackUnix::pack(fo);
// update loader