summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2014-11-17 23:15:45 +0100
committerMark Wielaard <[email protected]>2014-11-17 23:19:03 +0100
commit5c1a45c2d370e7fd1149fa74a9382e202fbfe8fe (patch)
treeb41fc506962bb78a5b9176600abd968146bc7e2b /backends
parent7df0da33f4789e264242a4cb8af30c0aefe6d6b4 (diff)
Check elf_strptr didn't fail getting section name.
Since elf_strptr can fail and return NULL we should always check the result before usage. Debug sections are only handled by section name, so make sure the name actually exists. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'backends')
-rw-r--r--backends/ChangeLog4
-rw-r--r--backends/ppc64_init.c15
2 files changed, 13 insertions, 6 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 82a2bf15..abd22bf8 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-17 Mark Wielaard <[email protected]>
+
+ * ppc64_init.c (ppc64_init): Check section name is not NULL.
+
2014-10-06 Mark Wielaard <[email protected]>
* libebl_CPU.h (dwarf_peel_type): Removed.
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
index 7ea2b236..56e1828e 100644
--- a/backends/ppc64_init.c
+++ b/backends/ppc64_init.c
@@ -90,13 +90,16 @@ ppc64_init (elf, machine, eh, ehlen)
if (opd_shdr != NULL
&& (opd_shdr->sh_flags & SHF_ALLOC) != 0
&& opd_shdr->sh_type == SHT_PROGBITS
- && opd_shdr->sh_size > 0
- && strcmp (elf_strptr (elf, ehdr->e_shstrndx,
- opd_shdr->sh_name), ".opd") == 0)
+ && opd_shdr->sh_size > 0)
{
- eh->fd_addr = opd_shdr->sh_addr;
- eh->fd_data = elf_getdata (scn, NULL);
- break;
+ const char *name = elf_strptr (elf, ehdr->e_shstrndx,
+ opd_shdr->sh_name);
+ if (name != NULL && strcmp (name, ".opd") == 0)
+ {
+ eh->fd_addr = opd_shdr->sh_addr;
+ eh->fd_data = elf_getdata (scn, NULL);
+ break;
+ }
}
}
}