From 6ca7fac2531b101aae1b9b7a4385f85eb19cdcc9 Mon Sep 17 00:00:00 2001 From: christos Date: Mon, 26 Oct 2015 15:14:33 +0000 Subject: [PATCH] use asprintf(3) --- external/gpl3/binutils/dist/binutils/arsup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/external/gpl3/binutils/dist/binutils/arsup.c b/external/gpl3/binutils/dist/binutils/arsup.c index 9ddc55d64a32..47f731747365 100644 --- a/external/gpl3/binutils/dist/binutils/arsup.c +++ b/external/gpl3/binutils/dist/binutils/arsup.c @@ -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)