diff options
| author | Ulrich Drepper <[email protected]> | 2008-01-18 19:59:08 +0000 |
|---|---|---|
| committer | Ulrich Drepper <[email protected]> | 2008-01-18 19:59:08 +0000 |
| commit | 35f08c4d52d0ffd9f8aa50f47b84de5603842b1f (patch) | |
| tree | 7def9d6d4ef3ffea169252d44325cb039294129d /libdw/dwarf_getpubnames.c | |
| parent | 4173bd8d5dd43413ba0635e2a74bc57a9478fb13 (diff) | |
propagate from branch 'com.redhat.elfutils.nickc.pending' (head 28d6423325f0cc14a133eb6b92a8c3604e437ba6)
to branch 'com.redhat.elfutils' (head 6ef48518ed8497626058574c787852bd939d46ee)
Diffstat (limited to 'libdw/dwarf_getpubnames.c')
| -rw-r--r-- | libdw/dwarf_getpubnames.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c index 6d07a3b7..91dad311 100644 --- a/libdw/dwarf_getpubnames.c +++ b/libdw/dwarf_getpubnames.c @@ -58,6 +58,7 @@ #include <sys/param.h> #include <libdwP.h> +#include <dwarf.h> static int @@ -93,11 +94,17 @@ get_offsets (Dwarf *dbg) /* Read the set header. */ int len_bytes = 4; Dwarf_Off len = read_4ubyte_unaligned_inc (dbg, readp); - if (len == 0xffffffff) + if (len == DWARF3_LENGTH_64_BIT) { len = read_8ubyte_unaligned_inc (dbg, readp); len_bytes = 8; } + else if (unlikely (len >= DWARF3_LENGTH_MIN_ESCAPE_CODE + && len <= DWARF3_LENGTH_MAX_ESCAPE_CODE)) + { + __libdw_seterrno (DWARF_E_INVALID_DWARF); + goto err_return; + } /* Now we know the offset of the first offset/name pair. */ mem[cnt].set_start = readp + 2 + 2 * len_bytes - startp; @@ -122,14 +129,17 @@ get_offsets (Dwarf *dbg) mem[cnt].cu_offset = read_8ubyte_unaligned (dbg, readp + 2); /* Determine the size of the CU header. */ - assert (dbg->sectiondata[IDX_debug_info] != NULL); - assert (dbg->sectiondata[IDX_debug_info]->d_buf != NULL); - assert (mem[cnt].cu_offset + 3 - < dbg->sectiondata[IDX_debug_info]->d_size); + if (dbg->sectiondata[IDX_debug_info] == NULL + || dbg->sectiondata[IDX_debug_info]->d_buf == NULL + || mem[cnt].cu_offset + 3 >= dbg->sectiondata[IDX_debug_info]->d_size) + { + __libdw_seterrno (DWARF_E_INVALID_DWARF); + goto err_return; + } unsigned char *infop = ((unsigned char *) dbg->sectiondata[IDX_debug_info]->d_buf + mem[cnt].cu_offset); - if (read_4ubyte_unaligned_noncvt (infop) == 0xffffffff) + if (read_4ubyte_unaligned_noncvt (infop) == DWARF3_LENGTH_64_BIT) mem[cnt].cu_header_size = 23; else mem[cnt].cu_header_size = 11; |
