From d615985b8a1b68bbdc0f31e0e6e648f93c434095 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Thu, 18 Jan 2024 19:11:12 -0800 Subject: [PATCH] elf_find_table_size() did not check for empty table https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65765&q=label%3AProj-upx https://github.com/upx/upx/issues/771 modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 52a84efd..c7541ab7 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -2046,6 +2046,9 @@ unsigned PackLinuxElf32::elf_find_table_size(unsigned dt_type, unsigned sh_type) unsigned x_rva; if (dt_type < DT_NUM) { unsigned const x_ndx = dt_table[dt_type]; + if (!x_ndx) { // no such entry + return 0; + } x_rva = get_te32(&dynseg[-1+ x_ndx].d_val); } else { @@ -7935,6 +7938,9 @@ unsigned PackLinuxElf64::elf_find_table_size(unsigned dt_type, unsigned sh_type) unsigned x_rva; if (dt_type < DT_NUM) { unsigned const x_ndx = dt_table[dt_type]; + if (!x_ndx) { // no such entry + return 0; + } x_rva = get_te64(&dynseg[-1+ x_ndx].d_val); } else {