From 31c91fbc0e8c98b4fd3389d014fdf0fc7bb2cfff Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 10 Nov 2000 03:24:41 +0000 Subject: [PATCH] Cleaned up blocksize handling. committer: mfx 973826681 +0000 --- src/p_lx_elf.cpp | 11 +++-------- src/p_lx_sep.cpp | 15 +++++++++------ src/p_lx_sh.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index cc1343ae..017b4dc5 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -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)); diff --git a/src/p_lx_sep.cpp b/src/p_lx_sep.cpp index 9461b427..a7221e3f 100644 --- a/src/p_lx_sep.cpp +++ b/src/p_lx_sep.cpp @@ -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() diff --git a/src/p_lx_sh.cpp b/src/p_lx_sh.cpp index 9015af8a..6e6eb511 100644 --- a/src/p_lx_sh.cpp +++ b/src/p_lx_sh.cpp @@ -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