|
From: <sv...@va...> - 2014-05-14 10:50:29
|
Author: mjw
Date: Wed May 14 10:50:14 2014
New Revision: 13962
Log:
Support -Wformat -Werror=format-security.
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.
Modified:
trunk/Makefile.tool-tests.am
trunk/NEWS
trunk/configure.ac
trunk/coregrind/m_gdbserver/remote-utils.c
Modified: trunk/Makefile.tool-tests.am
==============================================================================
--- trunk/Makefile.tool-tests.am (original)
+++ trunk/Makefile.tool-tests.am Wed May 14 10:50:14 2014
@@ -32,6 +32,10 @@
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
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed May 14 10:50:14 2014
@@ -119,6 +119,7 @@
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
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed May 14 10:50:14 2014
@@ -1681,6 +1681,31 @@
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])
Modified: trunk/coregrind/m_gdbserver/remote-utils.c
==============================================================================
--- trunk/coregrind/m_gdbserver/remote-utils.c (original)
+++ trunk/coregrind/m_gdbserver/remote-utils.c Wed May 14 10:50:14 2014
@@ -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;
|