Fix coverity issue - untrusted divisor 29/244129/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 15 Sep 2020 06:26:08 +0000 (08:26 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 15 Sep 2020 06:26:08 +0000 (08:26 +0200)
Change-Id: I85689dc3753e24ebec6ab88cd6e0e39f57cce442

src/crash-stack/unwind.c

index cda0e10..44bff5d 100644 (file)
@@ -409,7 +409,11 @@ static char *proc_name(int fd, char *image, size_t size, uint64_t load,
 
             void *data = teu_getsdata(elf, &shdr);
 
-            symbol_count = shdr.sh_size / shdr.sh_entsize;
+            if (shdr.sh_entsize == 0)
+                symbol_count = 0;
+            else
+                symbol_count = shdr.sh_size / shdr.sh_entsize;
+
             for (i = 0; i < (size_t)symbol_count; ++i) {
                 Elf64_Sym s;