From 592011b25160ed6bc476e6855784ed2a7c8f3bc6 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 20 Sep 2023 14:49:22 +0200 Subject: [PATCH] lib: clippy ELF: check existence of string table Mostly to make coverity happy, no compiler/linker should produce broken ELF files like this (and if it does we can't process it anyway...) Signed-off-by: David Lamparter --- lib/elf_py.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/elf_py.c b/lib/elf_py.c index 81ca668e70..643495d8c7 100644 --- a/lib/elf_py.c +++ b/lib/elf_py.c @@ -1089,7 +1089,9 @@ static void elffile_add_dynreloc(struct elffile *w, Elf_Data *reldata, symidx = relw->symidx = GELF_R_SYM(rela->r_info); sym = relw->sym = gelf_getsym(symdata, symidx, &relw->_sym); if (sym) { - relw->symname = elfdata_strptr(strdata, sym->st_name); + if (strdata) + relw->symname = elfdata_strptr(strdata, + sym->st_name); relw->symvalid = GELF_ST_TYPE(sym->st_info) != STT_NOTYPE; relw->unresolved = sym->st_shndx == SHN_UNDEF;