From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NHjyC-0005Z7-Ca for mharc-grub-devel@gnu.org; Mon, 07 Dec 2009 15:14:08 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHjyA-0005YA-E7 for grub-devel@gnu.org; Mon, 07 Dec 2009 15:14:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHjy6-0005Vn-8H for grub-devel@gnu.org; Mon, 07 Dec 2009 15:14:05 -0500 Received: from [199.232.76.173] (port=40966 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHjy5-0005Ve-FL for grub-devel@gnu.org; Mon, 07 Dec 2009 15:14:01 -0500 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:33652 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHjy4-0007Cy-QB for grub-devel@gnu.org; Mon, 07 Dec 2009 15:14:01 -0500 Received: from pinux (82-45-164-87.cable.ubr06.hari.blueyonder.co.uk [82.45.164.87]) by mail.pina.cat (Postfix) with ESMTP id 3725428415526 for ; Mon, 7 Dec 2009 21:13:58 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id D79BC34B89; Mon, 7 Dec 2009 20:14:08 +0000 (GMT) Date: Mon, 7 Dec 2009 20:14:08 +0000 From: Carles Pina i Estany To: The development of GNU GRUB Message-ID: <20091207201408.GA27276@pina.cat> References: <20091207140923.GA6439@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091207140923.GA6439@riva.ucam.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: Build failures on Ubuntu due to gettext X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2009 20:14:06 -0000 Hello, On Dec/07/2009, Colin Watson wrote: > Ubuntu's GCC enables -Wformat-security by default. This causes GCC to > (IMO rightly!) complain about constructs such as this: > > grub_printf (_("foo")); I see... (actually some weeks ago I thought about gettext security implications, and I thought that if someone can change the .mo files there is some bigger problem for the user... but I understand the point) > ... because it's all too easy for a translator to (usually > accidentally) insert % sequences which would cause printf to behave (side and non-relevant note: if the translator wants to do some damage on purpose he doesn't need to play with %s and %d, it's as easy as changing strings from "Press C to Cancel and D to delete" to something like (in another language) "Press D to Cancel and C to delete") > incorrectly. This should instead be: > > grub_printf ("%s", _("foo")); I like the general idea but I'm not 100% convinced of the implementation: a) It's a bit of false security because it's not fixing the case of file normal/menu_text.c, line 191 (search the string "Use the %C and %C keys to") or menu_text.c line 374 (search for "The highlighted entry") (I agree that it's better than before... but not very solid) b) How would you translate and handle: grub_printf (_("Hello %s"), name); The translator really needs "%s" because in other languages can be "%s hello" (not the best example but maybe you get the point) c) I'm thinking to implement grub_printf_ (str). I will send a patch later to see if everybody likes. Then the call for simple strings would be: grub_printf_ ("%s", N_("Hello")); Not much different from: grub_printf_ (N_("Hello")); But it's getting hard to print a string :-) d) (important, even if it's the last one): How it prevents mistakes from the current msgfmt checks? For example, and using the option -c in msgfmt: #: normal/misc.c:67 #, c-format msgid "test %s t" msgstr "test %d test2" /usr/bin/msgfmt -c --statistics -o po/ca.mo po/ca.po po/ca.po:1183: format specifications in 'msgid' and 'msgstr' for argument 1 are not the same /usr/bin/msgfmt: found 1 fatal error 26 translated messages, 213 untranslated messages. Using any different number of %X from msgid and msgstr ishalting msgfmt (so, if msgid contains 1 %s and 2 %d, msgstr has to contain the same) We are talking from _(" "), I see that -Wformat-security is for "string came from untrusted input and contains" when .mo are trusted. Are they? How are other projectes implementing it? Specially the dynamic strings. > Patch follows. I can't help thinking that this would be easier with a > grub_puts, but perhaps that isn't worth it given the relatively small > number of occurrences here? We could replace grub_puts with grub_printf... or some other idea. > Also, should the line in notify_execution_failure instead be: > > - grub_printf (_("Failed to boot default entries.\n")); > + grub_printf ("%s\n", _("Failed to boot default entries.")); > > ... to get rid of the unsightly \n in this translated string? I really like that this fix the \n discussion that we had :-) I like the idea and I understand that it's easy to make mistakes translating strings. Actually I'm surprised that msgfmt is not giving any warning if the -- Carles Pina i Estany http://pinux.info