Unpacking ELF requires e_phnum at least 2
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65535 https://github.com/upx/upx/issues/763 modified: p_lx_elf.cpp
This commit is contained in:
committed by
Markus F.X.J. Oberhumer
parent
d549c2b5c9
commit
d3e780d617
@@ -2420,6 +2420,9 @@ tribool PackLinuxElf32::canUnpack() // bool, except -1: format known, but not pa
|
|||||||
if (checkEhdr(&ehdri)) {
|
if (checkEhdr(&ehdri)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (get_te16(&ehdri.e_phnum) < 2) {
|
||||||
|
throwCantUnpack("e_phnum must be >= 2");
|
||||||
|
}
|
||||||
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||||
PackLinuxElf32help1(fi);
|
PackLinuxElf32help1(fi);
|
||||||
}
|
}
|
||||||
@@ -2966,6 +2969,9 @@ tribool PackLinuxElf64::canUnpack() // bool, except -1: format known, but not pa
|
|||||||
if (checkEhdr(&ehdri)) {
|
if (checkEhdr(&ehdri)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (get_te16(&ehdri.e_phnum) < 2) {
|
||||||
|
throwCantUnpack("e_phnum must be >= 2");
|
||||||
|
}
|
||||||
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||||
PackLinuxElf64help1(fi);
|
PackLinuxElf64help1(fi);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user