Fix coverity issue - untrusted divisor 71/244171/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 15 Sep 2020 11:00:44 +0000 (13:00 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 15 Sep 2020 11:00:44 +0000 (13:00 +0200)
Change-Id: I9be328f16c0a3a1b59652656f496218b2c51cc7d

src/crash-stack/unwind.c

index f984b92..be5b81a 100644 (file)
@@ -425,7 +425,11 @@ static char *proc_name(int fd, char *image, size_t size, uint64_t load,
                 goto proc_name_end;
             }
 
-            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;