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
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
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
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])
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;