]>
Commit | Line | Data |
---|---|---|
b48a27c4 JB |
1 | Avoid SIGFPE on semi-ELF files, like guile cache (*.go). |
2 | --- rpm-5.4.17/rpmdb/legacy.c.orig 2019-02-14 18:13:07.961620012 +0100 | |
3 | +++ rpm-5.4.17/rpmdb/legacy.c 2019-02-14 19:54:24.235368679 +0100 | |
4 | @@ -116,7 +116,7 @@ | |
5 | if (shdr.sh_type != SHT_DYNAMIC) | |
6 | continue; | |
7 | while (!bingo && (data = elf_getdata (scn, data)) != NULL) { | |
8 | - unsigned maxndx = (unsigned) (data->d_size / shdr.sh_entsize); | |
9 | + unsigned maxndx = (shdr.sh_entsize == 0) ? 0 : (unsigned) (data->d_size / shdr.sh_entsize); | |
10 | unsigned ndx; | |
11 | ||
12 | for (ndx = 0; ndx < maxndx; ++ndx) { | |
13 | --- rpm-5.4.17/lib/rpmds.c.orig 2019-02-14 21:51:17.514041154 +0100 | |
14 | +++ rpm-5.4.17/lib/rpmds.c 2019-02-14 21:51:20.570691261 +0100 | |
15 | @@ -2933,6 +2933,11 @@ | |
16 | * @param isX32 is this an X32 symbol? | |
17 | */ | |
18 | #if defined(HAVE_GELF_H) && defined(HAVE_LIBELF) && !defined(__FreeBSD__) | |
19 | +static int getShdrEntries(GElf_Shdr *shdr) | |
20 | +{ | |
21 | + return shdr->sh_entsize == 0 ? 0 : ((int)(shdr->sh_size / shdr->sh_entsize)); | |
22 | +} | |
23 | + | |
24 | static char * sonameDep(/*@returned@*/ char * t, const char * s, int isElf64, int isX32) | |
25 | /*@modifies t @*/ | |
26 | { | |
27 | @@ -3195,7 +3200,7 @@ | |
28 | case SHT_DYNAMIC: | |
29 | data = NULL; | |
30 | while ((data = elf_getdata (scn, data)) != NULL) { | |
31 | - for (cnt = 0; cnt < (int)(shdr->sh_size / shdr->sh_entsize); ++cnt) { | |
32 | + for (cnt = 0; cnt < getShdrEntries(shdr); ++cnt) { | |
33 | dyn = gelf_getdyn (data, cnt, &dyn_mem); | |
34 | if (dyn == NULL) | |
35 | /*@innerbreak@*/ break; | |
36 | @@ -3436,7 +3441,7 @@ | |
37 | case SHT_DYNAMIC: | |
38 | data = NULL; | |
39 | while ((data = elf_getdata (scn, data)) != NULL) { | |
40 | - for (cnt = 0; cnt < (int)(shdr->sh_size / shdr->sh_entsize); ++cnt) { | |
41 | + for (cnt = 0; cnt < getShdrEntries(shdr); ++cnt) { | |
42 | dyn = gelf_getdyn (data, cnt, &dyn_mem); | |
43 | if (dyn == NULL) | |
44 | /*@innerbreak@*/ break; |