aboutsummaryrefslogtreecommitdiff
path: root/bfd/ieee.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-06-21 10:54:04 +0100
committerNick Clifton <nickc@redhat.com>2017-06-21 10:54:04 +0100
commitc458d0079cc5e8ff29256355e6532ad2f96a8aa6 (patch)
tree1123be843eef3a6577d0f1093837f4be2d2236b5 /bfd/ieee.c
parentce49701009db42a9a53e5dcf172a6a211b1025b3 (diff)
downloadgdb-c458d0079cc5e8ff29256355e6532ad2f96a8aa6.zip
gdb-c458d0079cc5e8ff29256355e6532ad2f96a8aa6.tar.gz
gdb-c458d0079cc5e8ff29256355e6532ad2f96a8aa6.tar.bz2
Fix address violation when parsing a corrupt IEEE binary.
PR binutils/21633 * ieee.c (ieee_slurp_sections): Check for a NULL return from read_id. (ieee_archive_p): Likewise. (ieee_object_p): Likewise.
Diffstat (limited to 'bfd/ieee.c')
-rw-r--r--bfd/ieee.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 08d08d4..958a40b 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -1246,6 +1246,8 @@ ieee_slurp_sections (bfd *abfd)
/* Read section name, use it if non empty. */
name = read_id (&ieee->h);
+ if (name == NULL)
+ return FALSE;
if (name[0])
section->name = name;
@@ -1395,6 +1397,8 @@ ieee_archive_p (bfd *abfd)
(void) next_byte (&(ieee->h));
library = read_id (&(ieee->h));
+ if (library == NULL)
+ goto got_wrong_format_error;
if (strcmp (library, "LIBRARY") != 0)
goto got_wrong_format_error;
@@ -1922,9 +1926,13 @@ ieee_object_p (bfd *abfd)
ieee->section_table_size = 0;
processor = ieee->mb.processor = read_id (&(ieee->h));
+ if (processor == NULL)
+ goto got_wrong_format;
if (strcmp (processor, "LIBRARY") == 0)
goto got_wrong_format;
ieee->mb.module_name = read_id (&(ieee->h));
+ if (ieee->mb.module_name == NULL)
+ goto got_wrong_format;
if (abfd->filename == (const char *) NULL)
abfd->filename = xstrdup (ieee->mb.module_name);