[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] enforce use of G_GNUC_PRINTF attributes
From: |
Daniel P . Berrangé |
Subject: |
[PATCH 6/6] enforce use of G_GNUC_PRINTF attributes |
Date: |
Mon, 19 Dec 2022 08:02:05 -0500 |
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>
---
configure | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configure b/configure
index 26c7bc5154..b9abe19e16 100755
--- a/configure
+++ b/configure
@@ -1208,6 +1208,8 @@ 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 -Wsuggest-attribute=format
+add_to warn_flags -Wmissing-format-attribute
nowarn_flags=
add_to nowarn_flags -Wno-initializer-overrides
--
2.38.1
- [PATCH 0/6] enforce use of G_GNUC_PRINTF annotations, Daniel P . Berrangé, 2022/12/19
- [PATCH 1/6] disas: add G_GNUC_PRINTF to gstring_printf, Daniel P . Berrangé, 2022/12/19
- [PATCH 2/6] hw/xen: use G_GNUC_PRINTF/SCANF for various functions, Daniel P . Berrangé, 2022/12/19
- [PATCH 6/6] enforce use of G_GNUC_PRINTF attributes,
Daniel P . Berrangé <=
- [PATCH 5/6] tests: add G_GNUC_PRINTF for various functions, Daniel P . Berrangé, 2022/12/19
- [PATCH 3/6] tools/virtiofsd: add G_GNUC_PRINTF for logging functions, Daniel P . Berrangé, 2022/12/19
- [PATCH 4/6] util/error: add G_GNUC_PRINTF for various functions, Daniel P . Berrangé, 2022/12/19
- Re: [PATCH 0/6] enforce use of G_GNUC_PRINTF annotations, Paolo Bonzini, 2022/12/22