]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: clippy ELF: check existence of string table
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 12:49:22 +0000 (14:49 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 12:49:22 +0000 (14:49 +0200)
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 <equinox@opensourcerouting.org>
lib/elf_py.c

index 81ca668e709a99932110f66c326c89b3afc4806c..643495d8c76ffc00b5f4db43d4b89064db566667 100644 (file)
@@ -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;