diff options
author | Nick Clifton <nickc@redhat.com> | 2020-10-29 11:17:39 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-10-29 11:17:39 +0000 |
commit | 00c19b8e7879b5e256e7852bdac667466d7a42c2 (patch) | |
tree | 0367abf7d81ae3f32b49df0d0d09d45273da70dc /binutils/objcopy.c | |
parent | 0ad0e70c73205da6daeb27d2cc1eeae3e54bd3d0 (diff) | |
download | gdb-00c19b8e7879b5e256e7852bdac667466d7a42c2.zip gdb-00c19b8e7879b5e256e7852bdac667466d7a42c2.tar.gz gdb-00c19b8e7879b5e256e7852bdac667466d7a42c2.tar.bz2 |
Fix a potential illegal memory access by objcopy when extracting dwo sections.
PR 26805
* objcopy.c (is_dwo_section): Check for missing or short section
names.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r-- | binutils/objcopy.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index d777d74..ca35df0 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1268,8 +1268,15 @@ group_signature (asection *group) static bfd_boolean is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) { - const char *name = bfd_section_name (sec); - int len = strlen (name); + const char *name; + int len; + + if (sec == NULL || (name = bfd_section_name (sec)) == NULL) + return FALSE; + + len = strlen (name); + if (len < 5) + return FALSE; return strncmp (name + len - 4, ".dwo", 4) == 0; } |