]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Support -Wformat -Werror=format-security.
authorMark Wielaard <mark@klomp.org>
Wed, 14 May 2014 10:50:14 +0000 (10:50 +0000)
committerMark Wielaard <mark@klomp.org>
Wed, 14 May 2014 10:50:14 +0000 (10:50 +0000)
Check if gcc supports -Wformat -Werror=format-security and use it if so.
Fix m_gdbserver/remote-utils.c sr_perror call. Fixes Bug #334727.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13962

Makefile.tool-tests.am
NEWS
configure.ac
coregrind/m_gdbserver/remote-utils.c

index 6521afb4ac78ae0b73cec874b79c08fd8bf4ffb4..baefbd76bc6e3f7a84429476f6fdcea8754c246a 100644 (file)
@@ -32,6 +32,10 @@ if HAS_WRITE_STRINGS_WARNING
 CFLAGS += -Wno-write-strings
 endif
 
+if HAS_ERROR_FORMAT_SECURITY
+CFLAGS += -Wformat -Werror=format-security
+endif
+
 if COMPILER_IS_CLANG
 CFLAGS   += -Wno-format-extra-args       # perf/tinycc.c
 CFLAGS   += -Wno-literal-range           # none/tests/amd64/fxtract.c
diff --git a/NEWS b/NEWS
index e8f3b86195c47f1e292d21605e608fb68fdcb22b..2a3840cd313b247c237422c4cb5e8b9c5edb7fa3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -119,6 +119,7 @@ where XXXXXX is the bug number as listed below.
 333228  AAarch64 Missing instruction encoding: mrs %[reg], ctr_el0
 333230  AAarch64 missing instruction encodings: dc, ic, dsb.
 333666  Recognize MPX instructions and bnd prefix.
+334727  Build fails with -Werror=format-security
 n-i-bz  Fix KVM_CREATE_IRQCHIP ioctl handling
 n-i-bz  s390x: Fix memory corruption for multithreaded applications
 n-i-bz  vex arm->IR: allow PC as basereg in some LDRD cases
index af4228915a105d4b29b97caec2a6916330346be7..f3ba11dcb925998ba244f30f27cd4581e7d9f2db 100644 (file)
@@ -1681,6 +1681,31 @@ fi
 
 AM_CONDITIONAL(HAS_WRITE_STRINGS_WARNING, test x$no_write_strings = xyes)
 
+
+# does this compiler support -Wformat -Werror=format-security ?
+AC_MSG_CHECKING([if gcc accepts -Wformat -Werror=format-security])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wformat -Werror=format-security"
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  return 0;
+]])], [
+error_format_security=yes
+AC_MSG_RESULT([yes])
+], [
+error_format_security=no
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+if test x$no_write_strings = xyes; then
+  CFLAGS="$CFLAGS -Wformat -Werror=format-security"
+  CXXFLAGS="$CXXFLAGS -Wformat -Werror=format-security"
+fi
+
+AM_CONDITIONAL(HAS_ERROR_FORMAT_SECURITY, test x$error_format_security = xyes)
+
 # does this compiler support -Wno-empty-body ?
 
 AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
index d8dbe2a93c4f7324c9d0e8c573091801278a4ea7..b832d6983da5a23e7b38aa3f73f4a0a1ed449e86 100644 (file)
@@ -39,7 +39,7 @@
 static
 void sr_extended_perror (SysRes sr, const HChar *msg)
 {
-   sr_perror (sr, msg);
+   sr_perror (sr, "%s", msg);
    if (VG_(clo_verbosity) > 0 || VG_(debugLog_getLevel)() >= 1) {
       Int i;
       vki_sigset_t cursigset;