Module Name:    src
Committed By:   christos
Date:           Mon Oct 26 15:14:33 UTC 2015

Modified Files:
        src/external/gpl3/binutils/dist/binutils: arsup.c

Log Message:
use asprintf(3)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/gpl3/binutils/dist/binutils/arsup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/binutils/dist/binutils/arsup.c
diff -u src/external/gpl3/binutils/dist/binutils/arsup.c:1.1.1.2 src/external/gpl3/binutils/dist/binutils/arsup.c:1.2
--- src/external/gpl3/binutils/dist/binutils/arsup.c:1.1.1.2	Sat Sep 24 18:39:13 2011
+++ src/external/gpl3/binutils/dist/binutils/arsup.c	Mon Oct 26 11:14:33 2015
@@ -149,13 +149,20 @@ maybequit (void)
 void
 ar_open (char *name, int t)
 {
-  char *tname = (char *) xmalloc (strlen (name) + 10);
+  char *tname;
   const char *bname = lbasename (name);
   real_name = name;
 
   /* Prepend tmp- to the beginning, to avoid file-name clashes after
      truncation on filesystems with limited namespaces (DOS).  */
-  sprintf (tname, "%.*stmp-%s", (int) (bname - name), name, bname);
+  if (asprintf (&tname, "%.*stmp-%s", (int) (bname - name), name, bname) == -1)
+    {
+      fprintf (stderr, _("%s: Can't allocate memory for temp name (%s)\n"),
+	program_name, strerror(errno));
+      maybequit ();
+      return;
+    }
+
   obfd = bfd_openw (tname, NULL);
 
   if (!obfd)

Reply via email to