Blame SOURCES/29006.patch

fcd040
diff -rupN --no-dereference binutils-2.38/ld/pe-dll.c binutils-2.38-new/ld/pe-dll.c
fcd040
--- binutils-2.38/ld/pe-dll.c	2022-01-22 13:14:09.000000000 +0100
fcd040
+++ binutils-2.38-new/ld/pe-dll.c	2022-04-26 13:55:06.273552113 +0200
fcd040
@@ -2084,8 +2084,12 @@ make_head (bfd *parent)
fcd040
   char *oname;
fcd040
   bfd *abfd;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_d%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2173,8 +2177,12 @@ make_tail (bfd *parent)
fcd040
   char *oname;
fcd040
   bfd *abfd;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_d%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2324,8 +2332,12 @@ make_one (def_file_export *exp, bfd *par
fcd040
 	}
fcd040
     }
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_d%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2510,8 +2522,12 @@ make_singleton_name_thunk (const char *i
fcd040
   char *oname;
fcd040
   bfd *abfd;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_nmth%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_nmth%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2551,7 +2567,7 @@ make_import_fixup_mark (arelent *rel, ch
fcd040
   struct bfd_symbol *sym = *rel->sym_ptr_ptr;
fcd040
   bfd *abfd = bfd_asymbol_bfd (sym);
fcd040
   struct bfd_link_hash_entry *bh;
fcd040
-  char *fixup_name, buf[26];
fcd040
+  char *fixup_name, buf[256];
fcd040
   size_t prefix_len;
fcd040
 
fcd040
   /* "name" buffer has space before the symbol name for prefixes.  */
fcd040
@@ -2586,8 +2602,12 @@ make_import_fixup_entry (const char *nam
fcd040
   char *oname;
fcd040
   bfd *abfd;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_fu%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_fu%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2640,8 +2660,12 @@ make_runtime_pseudo_reloc (const char *n
fcd040
   bfd *abfd;
fcd040
   bfd_size_type size;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_rtr%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_rtr%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);
fcd040
@@ -2727,8 +2751,12 @@ pe_create_runtime_relocator_reference (b
fcd040
   char *oname;
fcd040
   bfd *abfd;
fcd040
 
fcd040
-  oname = xmalloc (20 + dll_symname_len);
fcd040
-  sprintf (oname, "%s_ertr%06d.o", dll_symname, tmp_seq);
fcd040
+  if (asprintf (&oname, "%s_ertr%06d.o", dll_symname, tmp_seq) < 4)
fcd040
+    /* In theory we should return NULL here at let our caller decide what to
fcd040
+       do.  But currently the return value is not checked, just used, and
fcd040
+       besides, this condition only happens when the system has run out of
fcd040
+       memory.  So just give up.  */
fcd040
+    exit (EXIT_FAILURE);
fcd040
   tmp_seq++;
fcd040
 
fcd040
   abfd = bfd_create (oname, parent);