From d4c40a8552466864602b548ec424cc2dc2d1c89e Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Wed, 28 Jan 2015 11:22:01 -0800 Subject: Some minor cleanups in two-level line table support. 2015-01-28 Cary Coutant binutils/ * dwarf.c (free_logicals): Set logicals_table to NULL. (fetch_indirect_string): Correct boundary check. (fetch_indirect_line_string): Likewise. (fetch_indexed_string): Likewise. (display_dir_file_table_v5): Print unsigned value. --- binutils/dwarf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index b666ae94065..f418cb118a8 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -424,6 +424,7 @@ free_logicals (void) free (logicals_table); logicals_allocated = 0; logicals_count = 0; + logicals_table = NULL; } static void @@ -643,7 +644,7 @@ fetch_indirect_string (dwarf_vma offset) if (section->start == NULL) return (const unsigned char *) _(""); - if (offset > section->size) + if (offset >= section->size) { warn (_("DW_FORM_strp offset too big: %s\n"), dwarf_vmatoa ("x", offset)); @@ -661,7 +662,7 @@ fetch_indirect_line_string (dwarf_vma offset) if (section->start == NULL) return (const unsigned char *) _(""); - if (offset > section->size) + if (offset >= section->size) { warn (_("DW_FORM_line_strp offset too big: %s\n"), dwarf_vmatoa ("x", offset)); @@ -688,7 +689,7 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, if (this_set != NULL) index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; - if (index_offset > index_section->size) + if (index_offset + offset_size > index_section->size) { warn (_("DW_FORM_GNU_str_index offset too big: %s\n"), dwarf_vmatoa ("x", index_offset)); @@ -701,7 +702,7 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, str_offset = byte_get (index_section->start + index_offset, offset_size); str_offset -= str_section->address; - if (str_offset > str_section->size) + if (str_offset >= str_section->size) { warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"), dwarf_vmatoa ("x", str_offset)); @@ -3031,7 +3032,7 @@ display_dir_file_table_v5 (unsigned char *start, unsigned char *end, case DW_FORM_udata: val = read_uleb128 (data, & bytes_read, end); data += bytes_read; - printf ("\t%d", val); + printf ("\t%u", val); break; default: printf ("\t%s", _("(unrecognized FORM code)")); -- cgit v1.2.1