Re: sharutils does not build with -Werror=format-security

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 10/12/2013 04:26 PM, Bruce Korb wrote:

>>   if (access (local_name, 4))
>>     {
>>       error (0, errno, _("Cannot access %s"), local_name);

In THIS form, xgettext recognizes the %s, and marks the string in the
.po file with an annotation that it appears to be a printf formatter,
and therefore gettext() will sanitize the translation to ensure that the
translation also supplies at most %s.

>>       else
>> -      error (0, errno, _("Cannot get current directory name"));
>> +      error (0, errno, "%s", _("Cannot get current directory name"));

but in THIS form, xgettext sees no % mark, so it does NOT mark the .po
file, and therefore gettext() no longer attempts to sanitize the
translation, and a translator can sneak in any % mark.  Yes, you can
argue that xgettext could be made smarter to properly annotate
string-literal formats with a printf annotation to force runtime
sanitization of the transalation, but for now, adding a "%s" format
argument is the easiest way to shut up the existing tool chain rather
than waiting for a fixed toolchain.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 621 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJSW/puAAoJEKeha0olJ0NqZmwH/1RA03RvDFlNkIK7otaiJFKv
5jV53qES/bmrBpDZF/lvbss8rUkzajNGwb+cJ8s8OOSL2ktwQ/PxSZkYAw3EEzaU
1G2iMpwB0kLRiZ3cZaEPwPtA8XTUgIczeFvUlSeRlWm/E8P654LySy08xGAKmE7d
f3AEarcMEwCkfRg6PPxP/5eN6ZSyaNkKh0zyKasvr/XErHobE20YofDjHGqjyf68
Ckdw3mojE5L70p4vATOc8agQPQmfZ9mc7DnMl9wJqFJYpXaK9sLvKXgvEJAPO1ff
W2raEcXJ1C96qoQhfY1GC6IYnzWJKN53ZlJcqQ+dDq/IwAtEqOyXOW/KLAt29Xw=
=V4vw
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.