public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: binutils@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PUSHED] opcodes/arm: don't pass non-string literal to printf like function
Date: Tue,  1 Nov 2022 11:18:02 +0000	[thread overview]
Message-ID: <20221101111802.1532080-1-aburgess@redhat.com> (raw)
In-Reply-To: <20221101105724.1527333-1-aburgess@redhat.com>

To my great shame.  After fixing the previous issue, yet another
problem showed up on a couple of the buildbots (but not all, I'm
guessing due to compiler version differences).

Again, I've pushed the fix for this issue.  I don't think there will
be any disagreement for this fix, but do let me know if there is and
I'm happy to provide an adjustment.

Once again, sorry for the breakage,

Andrew

---

The earlier commit:

  commit 6576bffe6cbbb53c5756b2fccd2593ba69b74cdf
  Date:   Thu Jul 7 13:43:45 2022 +0100

      opcodes/arm: add disassembler styling for arm

introduced two places where a register name was passed as the format
string to the disassembler's fprintf_styled_func callback.  This will
cause a warning from some compilers, like this:

  ../../binutils-gdb/opcodes/arm-dis.c: In function ‘print_mve_vld_str_addr’:
  ../../binutils-gdb/opcodes/arm-dis.c:6005:3: error: format not a string literal and no format arguments [-Werror=format-security]
   6005 |   func (stream, dis_style_register, arm_regnames[gpr]);
        |   ^~~~

This commit fixes these by using "%s" as the format string.
---
 opcodes/arm-dis.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 101b3f84dfe..31ed81f5a4e 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -6002,7 +6002,7 @@ print_mve_vld_str_addr (struct disassemble_info *info,
     add_sub = "-";
 
   func (stream, dis_style_text, "[");
-  func (stream, dis_style_register, arm_regnames[gpr]);
+  func (stream, dis_style_register, "%s", arm_regnames[gpr]);
   if (p == 1)
     {
       func (stream, dis_style_text, ", ");
@@ -8588,7 +8588,8 @@ print_insn_coprocessor_1 (const struct sopcode32 *opcodes,
 			      is_unpredictable = true;
 			    u_reg = value;
 			  }
-			func (stream, dis_style_register, arm_regnames[value]);
+			func (stream, dis_style_register, "%s",
+			      arm_regnames[value]);
 			break;
 		      case 'V':
 			if (given & (1 << 6))
-- 
2.25.4


  reply	other threads:[~2022-11-01 11:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 10:57 [PUSHED] opcodes/arm: silence compiler warning about uninitialized variable use Andrew Burgess
2022-11-01 11:18 ` Andrew Burgess [this message]
2022-11-04 11:01   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221101111802.1532080-1-aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).