]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix a segmentation fault triggered when trying to handle an unresolved PE symbol...
authorNick Clifton <nickc@redhat.com>
Mon, 15 Jun 2015 08:25:26 +0000 (09:25 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 15 Jun 2015 08:25:26 +0000 (09:25 +0100)
PR ld/18466
* emultempl/pe.em (pe_find_data_imports): Generate an error if a
symbol name is too long to handle.
* emultempl/pep.em (pep_find_data_imports): Likewise.

ld/ChangeLog
ld/emultempl/pe.em
ld/emultempl/pep.em

index a12e5c9106394bf0ad896a984f63a3377f3b1108..38dbb8bb35134d344e92b0c26e793cfcc2deb26e 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-15  Nick Clifton  <nickc@redhat.com>
+
+       PR ld/18466
+       * emultempl/pe.em (pe_find_data_imports): Generate an error if a
+       symbol name is too long to handle.
+       * emultempl/pep.em (pep_find_data_imports): Likewise.
+
 2015-06-12  Tristan Gingold  <gingold@adacore.com>
 
        * NEWS: Mention new option.
index 60882cef9095c174a17224d0af8355ab51637701..0a5dcbf6fba6c56f8dffc69f7f7133becf9f37f0 100644 (file)
@@ -1171,11 +1171,20 @@ pe_find_data_imports (void)
       if (undef->type == bfd_link_hash_undefined)
        {
          /* C++ symbols are *long*.  */
-         char buf[4096];
+#define BUF_SIZE 4096
+         char buf[BUF_SIZE];
 
          if (pe_dll_extra_pe_debug)
            printf ("%s:%s\n", __FUNCTION__, undef->root.string);
 
+         if (strlen (undef->root.string) > (BUF_SIZE - 6))
+           {
+             /* PR linker/18466.  */
+             einfo (_("%P: internal error: symbol too long: %s\n"),
+                    undef->root.string);
+             return;
+           }
+
          sprintf (buf, "__imp_%s", undef->root.string);
 
          sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);
index d6de792a7a66a07036f504f66316c5dd3edf01fa..bf362760dba49dac8c4c9ce396a919e435b12bde 100644 (file)
@@ -1151,11 +1151,20 @@ pep_find_data_imports (void)
       if (undef->type == bfd_link_hash_undefined)
        {
          /* C++ symbols are *long*.  */
-         char buf[4096];
+#define BUF_SIZE 4096
+         char buf[BUF_SIZE];
 
          if (pep_dll_extra_pe_debug)
            printf ("%s:%s\n", __FUNCTION__, undef->root.string);
 
+         if (strlen (undef->root.string) > (BUF_SIZE - 6))
+           {
+             /* PR linker/18466.  */
+             einfo (_("%P: internal error: symbol too long: %s\n"),
+                    undef->root.string);
+             return;
+           }
+
          sprintf (buf, "__imp_%s", undef->root.string);
 
          sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);