summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2009-05-06 15:51:20 +0200
committerPetr Machata <pmachata@redhat.com>2009-05-06 15:51:20 +0200
commit6fb192e360f842cacb34a90c03cd0524cccc3dec (patch)
treef6d48a0be63b7a754a17c3dcee1170ba192f9948
parenta2e7612b165d83dd241225f87075fa4f58d18781 (diff)
downloadelfutils-6fb192e360f842cacb34a90c03cd0524cccc3dec.tar.gz
Check for presence of data before loading the offset
-rw-r--r--libdw/ChangeLog4
-rw-r--r--libdw/dwarf_formudata.c14
2 files changed, 8 insertions, 10 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index ec32c2d8..11ac6e73 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -29,10 +29,8 @@
2009-04-23 Petr Machata <pmachata@redhat.com>
* libdwP.h (__libdw_read_addr_inc, __libdw_read_off_inc,
- __libdw_read_addr, __libdw_read_off): Declare four new internal
+ __libdw_read_addr, __libdw_read_off): Add four new internal
functions.
- * dwarf_readhooks.c: New file, implements the above.
- * Makefile.am (libdw_a_SOURCES): Add the new file
2009-04-15 Roland McGrath <roland@redhat.com>
diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c
index de0489db..35288851 100644
--- a/libdw/dwarf_formudata.c
+++ b/libdw/dwarf_formudata.c
@@ -63,6 +63,13 @@ __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
if (attr == NULL)
return NULL;
+ const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index];
+ if (unlikely (d == NULL))
+ {
+ __libdw_seterrno (err_nodata);
+ return NULL;
+ }
+
Dwarf_Word offset;
switch (attr->form)
{
@@ -79,13 +86,6 @@ __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
return NULL;
};
- const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index];
- if (unlikely (d == NULL))
- {
- __libdw_seterrno (err_nodata);
- return NULL;
- }
-
unsigned char *readp = d->d_buf + offset;
unsigned char *endp = d->d_buf + d->d_size;
if (unlikely (readp >= endp))