This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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]

[binutils-gdb] expprint: Fix format string warning


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d6b687ac7a2bfd0c3962f45ea5e1a72310f4e07e

commit d6b687ac7a2bfd0c3962f45ea5e1a72310f4e07e
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Tue Sep 5 09:00:42 2017 +0200

    expprint: Fix format string warning
    
    My compiler (gcc 5.4.0, clang 3.8) gives this warning:
    
    /home/emaisin/src/binutils-gdb/gdb/expprint.c: In lambda function:
    /home/emaisin/src/binutils-gdb/gdb/expprint.c:1055:35: error: format not a string literal and no format arguments [-Werror=format-security]
          fprintf_filtered (stream, mod);
                                       ^
    
    Fix it by not using the passed string as the format string.
    
    gdb/ChangeLog:
    
    	* expprint.c (dump_subexp_body_standard): Use constant format
    	string in fprintf_filtered call.

Diff:
---
 gdb/ChangeLog  | 5 +++++
 gdb/expprint.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index de1945a..19882f0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-05  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* expprint.c (dump_subexp_body_standard): Use constant format
+	string in fprintf_filtered call.
+
 2017-09-04  John Baldwin  <jhb@FreeBSD.org>
 
 	* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 2c16b49..9e04f24 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -1052,7 +1052,7 @@ dump_subexp_body_standard (struct expression *exp,
 	    if (space)
 	      fputs_filtered (" ", stream);
 	    space = true;
-	    fprintf_filtered (stream, mod);
+	    fprintf_filtered (stream, "%s", mod);
 	  };
 	if (flags & TYPE_INSTANCE_FLAG_CONST)
 	  print_one ("const");


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