Subject: | GCC complains about "croak(SvPV_nolen(buffer))" when compiling Params/Validate/XS.xs with -Werror=format-security |
When Params::Validate's XS module is compiled with
-Werror=format-security (as described in
http://article.gmane.org/gmane.comp.lang.perl.perl5.porters/105559), the
build fails with the following error message:
lib/Params/Validate/XS.xs: In function 'validate_named_depends':
lib/Params/Validate/XS.xs:1005:29: error: format not a string literal
and no format arguments [-Werror=format-security]
GCC complains about this function call:
croak(SvPV_nolen(buffer));
I don't know if "buffer" could contain format specifiers but passing
"%s" as the format string should be safer and makes GCC happy:
croak("%s", SvPV_nolen(buffer));
Subject: | lib_Params_Validate_XS_xs.diff.txt |
--- lib/Params/Validate/XS.xs 2012-02-08 10:08:42.000000000 +0100
+++ lib/Params/Validate/XS.xs.orig 2012-02-06 23:45:04.000000000 +0100
@@ -1002,7 +1002,7 @@
sv_catpv(buffer, "' does not exist in spec: ");
sv_catsv(buffer, depend_name);
- croak("%s", SvPV_nolen(buffer));
+ croak(SvPV_nolen(buffer));
}
/* if we got here, the spec was correct. we just
* need to issue a regular validation failure