This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gas/config/tc-score7.c: Use "%s" parameter instead of string parameter in sprintf().

sprintf() treat 2nd parameter as a string, and also recognize its'
special characters (e.g '%d'). If 'insnstr' may content special
characters in future, it may cause issue.

So recommend to use "%s" instead of. The related warning (build for

  In file included from ../../binutils-gdb/gas/config/tc-score.c:25:0:
  ../../binutils-gdb/gas/config/tc-score7.c: In function ‘s7_parse_pce_inst’:
  ../../binutils-gdb/gas/config/tc-score7.c:5340:7: warning: format not a string literal and no format arguments [-Wformat-security]

Signed-off-by: Chen Gang <>
 gas/config/tc-score7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index 0a0db2d..0bae545 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -5337,7 +5337,7 @@ s7_parse_pce_inst (char *insnstr)
       || ((pec_part_1.size == s7_INSN16_SIZE) && (s7_inst.size == s7_INSN_SIZE)))
       s7_inst.error = _("pce instruction error (16 bit || 16 bit)'");
-      sprintf (s7_inst.str, insnstr);
+      sprintf (s7_inst.str, "%s", insnstr);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]