[Bug,default/29346] SIGFPE when doing abipkgdiff --self-check of aisleriot-debuginfo-3.22.21-1.fc36.aarch64.rpm

Message ID bug-29346-9487-ki8d73lnyk@http.sourceware.org/bugzilla/
State New
Headers
Series [Bug,default/29346] SIGFPE when doing abipkgdiff --self-check of aisleriot-debuginfo-3.22.21-1.fc36.aarch64.rpm |

Commit Message

mark at klomp dot org July 9, 2022, 8:29 p.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=29346

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
I probably should have tried to compile it at least.
This actually compiles (but I haven't replicated the original issue):

           if (data == NULL)
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 32a2cead..f2f06037 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -16634,8 +16634,11 @@  get_soname_of_elf_file(const string& path, string
&soname)
           Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset);
           GElf_Shdr shdr_mem;
           GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem);
+          size_t entsize = (shdr != NULL && shdr->sh_entsize != 0
+                            ? shdr->sh_entsize
+                           : gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT));
           int maxcnt = (shdr != NULL
-                        ? shdr->sh_size / shdr->sh_entsize : INT_MAX);
+                        ? shdr->sh_size / entsize : INT_MAX);
           ABG_ASSERT (shdr == NULL || shdr->sh_type == SHT_DYNAMIC);
           Elf_Data* data = elf_getdata (scn, NULL);