From 780c64e1f09bf7400b94aab594e1993ac97e0557 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Dec 2020 18:37:53 +0100 Subject: [PATCH] LibELF: Fix ELF::Image::symbol_count() asserting on section-less ELF If we have no sections, we also have no symbols, so just return 0. Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28683 --- Libraries/LibELF/Image.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/LibELF/Image.cpp b/Libraries/LibELF/Image.cpp index d91c9558ab..085cb97aa3 100644 --- a/Libraries/LibELF/Image.cpp +++ b/Libraries/LibELF/Image.cpp @@ -76,6 +76,8 @@ StringView Image::section_index_to_string(unsigned index) const unsigned Image::symbol_count() const { ASSERT(m_valid); + if (!section_count()) + return 0; return section(m_symbol_table_section_index).entry_count(); }