diff options
author | Alan Modra <amodra@gmail.com> | 2017-10-01 21:40:23 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-10-01 21:41:16 +1030 |
commit | bfec0f11eadd7ed3597bc9b550a5595421a4cb31 (patch) | |
tree | bc1f29533bf2fb7179798f0a20a249e729ee3a21 | |
parent | 8cb1232a8cc0d1a6db2de51398acfe978a5c7e68 (diff) | |
download | gdb-bfec0f11eadd7ed3597bc9b550a5595421a4cb31.zip gdb-bfec0f11eadd7ed3597bc9b550a5595421a4cb31.tar.gz gdb-bfec0f11eadd7ed3597bc9b550a5595421a4cb31.tar.bz2 |
PR22232, NULL pointer dereference in load_specific_debug_section
PR 22232
PR 22230
* objdump.c (load_specific_debug_section): Introduce a temp to
stop bfd_get_full_section_contents NULLing out section->start.
-rw-r--r-- | binutils/ChangeLog | 7 | ||||
-rw-r--r-- | binutils/objdump.c | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index d45eeaf..95cf50b 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,12 @@ 2017-10-01 Alan Modra <amodra@gmail.com> + PR 22232 + PR 22230 + * objdump.c (load_specific_debug_section): Introduce a temp to + stop bfd_get_full_section_contents NULLing out section->start. + +2017-10-01 Alan Modra <amodra@gmail.com> + PR 22230 * objdump.c (load_specific_debug_section): Allocate an extra byte for a terminating NUL. diff --git a/binutils/objdump.c b/binutils/objdump.c index 83b8b2a..98c316a 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -2465,6 +2465,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, { struct dwarf_section *section = &debug_displays [debug].section; bfd *abfd = (bfd *) file; + bfd_byte *contents; bfd_boolean ret; /* If it is already loaded, do nothing. */ @@ -2475,10 +2476,10 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, section->num_relocs = 0; section->address = bfd_get_section_vma (abfd, sec); section->size = bfd_get_section_size (sec); - section->start = malloc (section->size + 1); + section->start = contents = malloc (section->size + 1); section->user_data = sec; if (section->start == NULL - || !bfd_get_full_section_contents (abfd, sec, §ion->start)) + || !bfd_get_full_section_contents (abfd, sec, &contents)) { free_debug_section (debug); printf (_("\nCan't get contents for section '%s'.\n"), |