[Libvir] PATCH: Avoid format string abuse (also avoids gcc warnings).

Jim Meyering jim at meyering.net
Tue Nov 6 19:54:37 UTC 2007


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> On Tue, Nov 06, 2007 at 08:31:06PM +0100, Jim Meyering wrote:
>> This patch was prompted by warnings like this:
>>
>>   util.c:56: warning: format not a string literal and no format arguments
>
> Hmm, what compiler version are you using ? I don't see those warnings when
> I build. Or did you add extra compiler flags ? If the latter we should
> make sure they're included in our default flag set so we don't reintroduce
> similar flaws in the future.

gcc snapshot build a week or two ago on rawhide, but these options aren't new.
I always use -Wformat and -Wformat-security.  Here's a patch:

	* acinclude.m4 (minimum): Add -Wformat and -Wformat-security.

diff --git a/acinclude.m4 b/acinclude.m4
index 15bb7ff..1c4051d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -26,7 +26,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
         try_compiler_flags=""
 	;;
     minimum)
-	try_compiler_flags="-Wall $common_flags"
+	try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
 	;;
     yes)
 	try_compiler_flags="-Wall -Wmissing-prototypes $common_flags"




More information about the libvir-list mailing list