1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00

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:
John Reiser 2024-01-10 14:07:58 -08:00 committed by Markus F.X.J. Oberhumer
parent d549c2b5c9
commit d3e780d617

View File

@ -2420,6 +2420,9 @@ tribool PackLinuxElf32::canUnpack() // bool, except -1: format known, but not pa
if (checkEhdr(&ehdri)) {
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)) {
PackLinuxElf32help1(fi);
}
@ -2966,6 +2969,9 @@ tribool PackLinuxElf64::canUnpack() // bool, except -1: format known, but not pa
if (checkEhdr(&ehdri)) {
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)) {
PackLinuxElf64help1(fi);
}