Description of problem ---------------------- elfutils fails to build if "-Werror=format-security" flag is used. ... cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security] ... We are working on a proposal to enable "-Werror=format-security" for all packages. Once this flag is enabled, GCC will refuse to compile code that could be vulnerable to a string format security flaw. For more details, please see https://fedorahosted.org/fesco/ticket/1185 page. To understand why it is important to fix this, please see https://fedoraproject.org/wiki/Format-Security-FAQ page. How to fix this --------------- The fix for these errors is quite simple. It's a matter of changing a line like, printf(foo); to read, printf("%s", foo); That's it. Please fix this issue in rawhide with a patch (which you should submit to upstream to merge moving forward). Please do a new build with the fix in rawhide. Other releases do not need to be directly fixed, but there should be no harm in pushing out this fix/patch with other needed changes to those branches. In the event you don't fix this bug before the next mass rebuild, provenpackagers may step in and update your package(s) to fix this issue. How reproducible ---------------- Build elfutils-0.157-2.fc21.src.rpm with "-Werror=format-security" flag to reproduce the problem. To make this process easier, you can use a modified "redhat-rpm-config" package from http://people.fedoraproject.org/~halfie/artifacts/redhat-rpm-config/ URL. $ sha256sum redhat-rpm-config-9.1.0-56.fc20.* faad7594b2080fe76497d0ce50808c905a93dd7b41c1defdde5ca57e3833d3d2 redhat-rpm-config-9.1.0-56.fc20.noarch.rpm 5aa9357174305c7285ffdbc92d7ffe1c07a8a95d5459b930461308f5aad75413 redhat-rpm-config-9.1.0-56.fc20.src.rpm
(In reply to Dhiru Kholia from comment #0) > elfutils fails to build if "-Werror=format-security" flag is used. > > ... > > cc1: error: -Wformat-security ignored without -Wformat > [-Werror=format-security] > > ... > > Please fix this issue in rawhide with a patch (which you should submit > to upstream to merge moving forward). Please do a new build with the > fix in rawhide. Other releases do not need to be directly fixed, but > there should be no harm in pushing out this fix/patch with other needed > changes to those branches. > > In the event you don't fix this bug before the next mass rebuild, > provenpackagers may step in and update your package(s) to fix this > issue. Help with fixes that are acceptable upstream would be very appreciated since the given trivial example doesn't seem to match the patterns used in elfutils. So it is not as trivial as the example makes it out. See for some discussion of the issue to resolve this fedora devel thread https://lists.fedoraproject.org/pipermail/devel/2013-November/192309.html (no replies or suggestions yet).
Well, we already snip -Wall from RPM_OPT_FLAGS. We can just as well snip out the -Werror=format-security bit as well, on the grounds that we enable it again through the build system anyway, where relevant.
> Well, we already snip -Wall from RPM_OPT_FLAGS. We can just as well snip > out the -Werror=format-security bit as well, on the grounds that we enable > it again through the build system anyway, where relevant. Agreed. That would be the simplest. Another would be to explicitly mark the places in the code with: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-security" [... code ...] #pragma GCC diagnostic pop But if there is a more clean way that would be nice.(In reply to Petr Machata from comment #2)
0.157-4 Remove -Werror=format-security from RPM_OPT_FLAGS. diff --git a/elfutils.spec b/elfutils.spec index c41e98d..c139c19 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -231,7 +231,11 @@ find . -name \*.sh ! -perm -0100 -print | xargs chmod +x # Remove -Wall from default flags. The makefiles enable enough warnings # themselves, and they use -Werror. Appending -Wall defeats the cases where # the makefiles disable some specific warnings for specific code. +# Also remove -Werror=format-security which doesn't work without +# -Wformat (enabled by -Wall). We enable -Wformat explicitly for some +# files later. RPM_OPT_FLAGS=${RPM_OPT_FLAGS/-Wall/} +RPM_OPT_FLAGS=${RPM_OPT_FLAGS/-Werror=format-security/} %if %{compat} # Some older glibc headers can run afoul of -Werror all by themselves.
Proposed upstream patch: https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-January/003783.html
This has been worked around in fedora since 0.157-4 Remove -Werror=format-security from RPM_OPT_FLAGS. And upstream now explicitly builds with -Wformat=2 which includes -Wformat-security. commit f48eb6b15fee66e54b488d71738979fc608f25ee Author: Mark Wielaard <mjw> Date: Thu Jan 23 00:56:41 2014 +0100 Use -Wformat=2 by default for all files. This just makes sure that all format strings are given as literals to printf like functions so the compiler can see and check them. Remove all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS. Signed-off-by: Mark Wielaard <mjw>