Fix build id reading when the binary don't have it 56/230056/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 7 Apr 2020 11:27:12 +0000 (13:27 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 7 Apr 2020 11:32:51 +0000 (13:32 +0200)
Change-Id: I82db306cad980104e096e8b738db24fc5e3547bb

src/crash-manager/so-info.c

index 678638a..b3f76a9 100644 (file)
@@ -85,13 +85,13 @@ static unsigned char *map_file(const char *filename, int64_t *size)
 static Elf##bits##_Off build_id_section_address##bits(const unsigned char *mapped_file, const int64_t size)\
 {\
        if (mapped_file <= 0)\
-               return -1;\
+               return 0;\
 \
        Elf##bits##_Ehdr *elheader = (Elf##bits##_Ehdr*)mapped_file;\
        Elf##bits##_Shdr *sec = (Elf##bits##_Shdr*)(mapped_file + elheader->e_shoff);\
 \
        if (size < (intptr_t)sec + elheader->e_shstrndx*sizeof(Elf##bits##_Shdr) - (intptr_t)mapped_file)\
-               return -2;\
+               return 0;\
 \
        char *names = (char *)(mapped_file + sec[elheader->e_shstrndx].sh_offset);\
 \
@@ -102,7 +102,7 @@ static Elf##bits##_Off build_id_section_address##bits(const unsigned char *mappe
                        return sec[i].sh_offset;\
        } \
 \
-       return -1;\
+       return 0;\
 } \
 
 DECLARE_BUILD_ID_SECTION_ADDRESS(32)
@@ -157,10 +157,12 @@ static int get_build_id(char *filename, char **build_id)
 
        if (mapped_file > 0) {
                Elf64_Off offset = build_id_section_address(mapped_file, size);
-               if (offset > 0)
+               if (offset > 0) {
                        ret = get_build_id_from(mapped_file, offset, build_id);
-               else
+               } else {
+                       _W("File %s doesn't contain build-id", filename);
                        ret = -1;
+               }
 
                munmap(mapped_file, size);
        } else {