aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-10-19 16:02:49 +0100
committerNick Clifton <nickc@redhat.com>2021-10-19 16:02:49 +0100
commitcf487499e0d7ef64ab63d6c76bf298bfaf64b980 (patch)
tree122027a0a59f41ba89e2cd5c5a991a0cf2e76f6f
parentd4ef5e75c7ebf57b946f59ce85568b9c459a02f4 (diff)
downloadgdb-cf487499e0d7ef64ab63d6c76bf298bfaf64b980.zip
gdb-cf487499e0d7ef64ab63d6c76bf298bfaf64b980.tar.gz
gdb-cf487499e0d7ef64ab63d6c76bf298bfaf64b980.tar.bz2
Fix a potential illegal memory access when testing for a special LTO symbol name.
bfd * linker.c (_bfd_generic_link_add_one_symbol): Test for a NULL name before checking to see if the symbol is __gnu_lto_slim. * archive.c (_bfd_compute_and_write_armap): Likewise. binutils * nm.c (filter_symbols): Test for a NULL name before checking to see if the symbol is __gnu_lto_slim. * objcopy.c (filter_symbols): Likewise.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/archive.c3
-rw-r--r--bfd/linker.c1
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/nm.c3
-rw-r--r--binutils/objcopy.c3
6 files changed, 19 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2a08ff7..d539dbb 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2021-10-19 Nick Clifton <nickc@redhat.com>
+
+ * linker.c (_bfd_generic_link_add_one_symbol): Test for a NULL
+ name before checking to see if the symbol is __gnu_lto_slim.
+ * archive.c (_bfd_compute_and_write_armap): Likewise.
+
2021-09-27 Nick Alcock <nick.alcock@oracle.com>
* configure: Regenerate.
diff --git a/bfd/archive.c b/bfd/archive.c
index 2ac680d..dc17356 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -2357,7 +2357,8 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
map = new_map;
}
- if (syms[src_count]->name[0] == '_'
+ if (syms[src_count]->name != NULL
+ && syms[src_count]->name[0] == '_'
&& syms[src_count]->name[1] == '_'
&& strcmp (syms[src_count]->name
+ (syms[src_count]->name[2] == '_'),
diff --git a/bfd/linker.c b/bfd/linker.c
index f8257ea..3019dae 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1420,6 +1420,7 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
{
row = COMMON_ROW;
if (!bfd_link_relocatable (info)
+ && name != NULL
&& name[0] == '_'
&& name[1] == '_'
&& strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 0d5e4a0..192de3c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2021-10-19 Nick Clifton <nickc@redhat.com>
+
+ * nm.c (filter_symbols): Test for a NULL name before checking to
+ see if the symbol is __gnu_lto_slim.
+ * objcopy.c (filter_symbols): Likewise.
+
2021-09-30 Nick Clifton <nickc@redhat.com>
* objcopy.c (filter_symbols): Fail if attempting to dredefine
diff --git a/binutils/nm.c b/binutils/nm.c
index 82ccec6..7606956 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -544,7 +544,8 @@ filter_symbols (bfd *abfd, bool is_dynamic, void *minisyms,
if (sym == NULL)
bfd_fatal (bfd_get_filename (abfd));
- if (sym->name[0] == '_'
+ if (sym->name != NULL
+ && sym->name[0] == '_'
&& sym->name[1] == '_'
&& strcmp (sym->name + (sym->name[2] == '_'), "__gnu_lto_slim") == 0
&& report_plugin_err)
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 75fd89d..0e7400f 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1542,7 +1542,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
{
char *new_name;
- if (name[0] == '_'
+ if (name != NULL
+ && name[0] == '_'
&& name[1] == '_'
&& strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
{