summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-12-19 08:02:05 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2023-01-11 10:44:34 +0100
commit88a0ef00d70c61fdb46ee88ced87046dfb11eb3f (patch)
tree981808331f53cefd9ef7a7ce6ebe28b578db5795
parent0472b2e541971d162a9bbca7541c8f9299e9d78f (diff)
downloadfocaccia-qemu-88a0ef00d70c61fdb46ee88ced87046dfb11eb3f.tar.gz
focaccia-qemu-88a0ef00d70c61fdb46ee88ced87046dfb11eb3f.zip
enforce use of G_GNUC_PRINTF attributes
We've been very gradually adding G_GNUC_PRINTF annotations
to functions over years. This has been useful in detecting
certain malformed printf strings, or cases where we pass
user data as the printf format which is a potential security
flaw.

Given the inherant memory corruption danger in use of format
strings vs mis-matched variadic arguments, it is worth applying
G_GNUC_PRINTF to all functions using printf, even if we know
they are safe.

The compilers can reasonably reliably identify such places
with the -Wsuggest-attribute=format / -Wmissing-format-attribute
flags.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219130205.687815-7-berrange@redhat.com>
[-Wsuggest-attribute=format and -Wmissing-format-attribute are
 synonyms, only include one; disable it for testfloat. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-xconfigure1
-rw-r--r--tests/fp/meson.build1
2 files changed, 2 insertions, 0 deletions
diff --git a/configure b/configure
index 6f5e77a713..643aed7533 100755
--- a/configure
+++ b/configure
@@ -1183,6 +1183,7 @@ add_to warn_flags -Wnested-externs
 add_to warn_flags -Wendif-labels
 add_to warn_flags -Wexpansion-to-defined
 add_to warn_flags -Wimplicit-fallthrough=2
+add_to warn_flags -Wmissing-format-attribute
 
 nowarn_flags=
 add_to nowarn_flags -Wno-initializer-overrides
diff --git a/tests/fp/meson.build b/tests/fp/meson.build
index 6258e2bd7d..312a4d301f 100644
--- a/tests/fp/meson.build
+++ b/tests/fp/meson.build
@@ -37,6 +37,7 @@ tfcflags = [
   '-Wno-missing-prototypes',
   '-Wno-return-type',
   '-Wno-unused-function',
+  '-Wno-missing-format-attribute',
   '-Wno-error',
 ]