1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Merge branch 'devel' into jreiser-android

This commit is contained in:
John Reiser 2018-01-13 09:25:55 -08:00
commit e8ef0cf63f
4 changed files with 12 additions and 12 deletions

View File

@ -594,7 +594,9 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location, upx_ui
void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strcmp(type, "R_ARM_PC24") == 0) {
if (!strcmp(type, "R_ARM_PC24")
|| !strcmp(type, "R_ARM_CALL")
|| !strcmp(type, "R_ARM_JUMP24")) {
value -= rel->section->offset + rel->offset;
set_be24(1 + location, get_be24(1 + location) + value / 4);
} else if (strcmp(type, "R_ARM_ABS32") == 0) {
@ -618,7 +620,9 @@ void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location, upx_ui
void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strcmp(type, "R_ARM_PC24") == 0) {
if (!strcmp(type, "R_ARM_PC24")
|| !strcmp(type, "R_ARM_CALL")
|| !strcmp(type, "R_ARM_JUMP24")) {
value -= rel->section->offset + rel->offset;
set_le24(location, get_le24(location) + value / 4);
} else if (strcmp(type, "R_ARM_ABS32") == 0) {

View File

@ -3916,7 +3916,7 @@ PackLinuxElf32::check_pt_dynamic(Elf32_Phdr const *const phdr)
{
unsigned t = get_te32(&phdr->p_offset), s = sizeof(Elf32_Dyn) + t;
unsigned filesz = get_te32(&phdr->p_filesz), memsz = get_te32(&phdr->p_memsz);
if (s < t || file_size < s
if (s < t || file_size < (off_t)s
|| (3 & t) || (7 & (filesz | memsz)) // .balign 4; 8==sizeof(Elf32_Dyn)
|| filesz < sizeof(Elf32_Dyn)
|| memsz < sizeof(Elf32_Dyn)
@ -3987,7 +3987,7 @@ PackLinuxElf64::check_pt_dynamic(Elf64_Phdr const *const phdr)
{
upx_uint64_t t = get_te64(&phdr->p_offset), s = sizeof(Elf64_Dyn) + t;
upx_uint64_t filesz = get_te64(&phdr->p_filesz), memsz = get_te64(&phdr->p_memsz);
if (s < t || (uint64_t)file_size < s
if (s < t || (upx_uint64_t)file_size < s
|| (7 & t) || (0xf & (filesz | memsz)) // .balign 8; 16==sizeof(Elf64_Dyn)
|| filesz < sizeof(Elf64_Dyn)
|| memsz < sizeof(Elf64_Dyn)

View File

@ -1366,7 +1366,6 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
unsigned const sz_threado = threado_size();
MemBuffer space(sz_threado); memset(space, 0, sz_threado);
fo->write(space, sz_threado);
sz_mach_headers = fo->getBytesWritten();
}
else if (my_filetype == Mach_header::MH_DYLIB) {
Mach_command const *ptr = (Mach_command const *)rawmseg;
@ -1398,13 +1397,10 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
}
memset(&linkitem, 0, sizeof(linkitem));
fo->write(&linkitem, sizeof(linkitem));
fo->write(rawmseg, mhdri.sizeofcmds);
gap = secTEXT.offset - sz_mach_headers;
}
sz_mach_headers = fo->getBytesWritten();
MemBuffer filler(gap);
memset(filler, 0, gap);
gap = secTEXT.offset - sz_mach_headers;
MemBuffer filler(gap); filler.clear();
fo->write(filler, gap);
sz_mach_headers += gap;
@ -1978,7 +1974,7 @@ bool PackMachBase<T>::canPack()
strncpy(fsm.segZERO.segname, "__PAGEZERO", sizeof(fsm.segZERO.segname));
fsm.segZERO.vmaddr = 0;
fsm.segZERO.vmsize = (4<<16);
if (8==sizeof(void *)) fsm.segZERO.vmsize <<= (32 - 18);
if __acc_cte(8==sizeof(void *)) fsm.segZERO.vmsize <<= (32 - 18);
fsm.segZERO.fileoff = 0;
fsm.segZERO.filesize = 0;
fsm.segZERO.maxprot = 0;

View File

@ -167,7 +167,7 @@ int PeFile::readFileHeader()
: (h.p512*512+h.m512 - h.m512 ? 512 : 0);
if ((pe_offset + delta) < delta // wrap-around
|| (pe_offset + delta) > file_size) {
|| (pe_offset + delta) > (unsigned)file_size) {
char buf[64]; snprintf(buf, sizeof(buf),
"bad PE delta %#x at offset %#x", delta, pe_offset);
throwCantPack(buf);