From dbc6a0e2e4bdc70133d9165fb2e15b592bc27c53 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 17 Dec 2021 08:07:30 +1030 Subject: [PATCH] try_build_id_prefix gcc-10 -Wformat-security errors dwarf.c:11300:3: error: format not a string literal and no format arguments [-Werror=format-security] 11300 | f += sprintf (f, prefix); PR 28697 * dwarf.c (try_build_id_prefix): Avoid -Wformat-security error. --- binutils/dwarf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 12c5b0a8fa2..82ea3c62739 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -11297,12 +11297,11 @@ try_build_id_prefix (const char * prefix, char * filename, const unsigned char * { char * f = filename; - f += sprintf (f, prefix); - f += sprintf (f, ".build-id/%02x/", (unsigned) *data++); + f += sprintf (f, "%s.build-id/%02x/", prefix, (unsigned) *data++); id_len --; while (id_len --) f += sprintf (f, "%02x", (unsigned) *data++); - f += sprintf (f, ".debug"); + strcpy (f, ".debug"); return open_debug_file (filename); } -- 2.30.2