Fix rotate+lop of PT_INTERP in shared library
Found while working on https://github.com/upx/upx/issues/262 but probably does not help that bug. modified: p_lx_elf.cpp
This commit is contained in:
+8
-6
@@ -426,9 +426,10 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
|||||||
// by decrementing e_phnum.
|
// by decrementing e_phnum.
|
||||||
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract
|
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract
|
||||||
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
|
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
|
||||||
memcpy(&phdr[-1+ e_phnum], (unsigned char *)ibuf, sizeof(*phdr)); // to top
|
memcpy(&phdr[e_phnum - (1+ j)], (unsigned char *)ibuf, sizeof(*phdr)); // to top
|
||||||
--phdr;
|
--phdr; --e_phnum;
|
||||||
set_te16(&ehdri.e_phnum, --e_phnum);
|
set_te16(&ehdri.e_phnum, e_phnum);
|
||||||
|
set_te16(&((Elf32_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (PT_LOAD32 == type) {
|
if (PT_LOAD32 == type) {
|
||||||
@@ -550,9 +551,10 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
|||||||
// by decrementing e_phnum.
|
// by decrementing e_phnum.
|
||||||
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract
|
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract
|
||||||
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
|
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
|
||||||
memcpy(&phdr[-1+ e_phnum], (unsigned char *)ibuf, sizeof(*phdr)); // to top
|
memcpy(&phdr[e_phnum - (1+ j)], (unsigned char *)ibuf, sizeof(*phdr)); // to top
|
||||||
--phdr;
|
--phdr; --e_phnum;
|
||||||
set_te16(&ehdri.e_phnum, --e_phnum);
|
set_te16(&ehdri.e_phnum, e_phnum);
|
||||||
|
set_te16(&((Elf64_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (PT_LOAD64 == type) {
|
if (PT_LOAD64 == type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user