bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Translatable strings not marked 'c-format'


From: Ask Hjorth Larsen
Subject: Re: Translatable strings not marked 'c-format'
Date: Mon, 25 Jun 2018 17:14:05 +0200

Dear Nick and other developers,

Returning to this old issue (e.g.
https://www.mail-archive.com/address@hidden/msg26950.html),

2016-10-15 18:51 GMT+02:00 Ask Hjorth Larsen <address@hidden>:
> Dear developers
>
> In the translation template for bfd [1], very few strings have the
> c-format tag which makes gettext able to tell if placeholders (%s, %d,
> ...) are mistranslated.  This typically affects the substitution codes
> %B and %A.
>
> It is very unlikely that any translator can translate all 1400 strings
> without a single error in the substitution codes, which could have
> nasty consequences - I think.  Can this be improved somehow?
>
> Best regards
> Ask

I would like to make sure that the error was eventually resolved.  The
BFD template was recently updated, resulting in this kind of change in
the translation templates:

#: aout-cris.c:256
#, fuzzy, c-format
#| msgid "%B: Bad relocation record imported: %d"
msgid "%pB: bad relocation record imported: %d"
msgstr "%B: Fejlagtig relokeringspost importeret: %d"

Now, as a translator I am supposed to change %B into %pB in the msgstr
line, remove the fuzzy flag, and done.  This is fine.

If I omit or mis-spell %p or %d, then msgfmt (which checks the syntax
and compiles the translation template into a binary hashtable of
messages to be used runtime) will complain loudly.

But what if by accident I change it to %pA?  In between the thousands
of messages and dozens of languages, the probability of this happening
approaches one (Murphy's law).  I mischievously typed "%pA" instead,
and it produced no error.  Now we can be pretty certain that these
errors will happen at runtime, and the question is whether the
formatting functions handle them gracefully, crash, or output things
from random places in memory.

For example this translation will pass the msgfmt check, but certainly
shouldn't:

#: aout-cris.c:256
#, c-format
msgid "%pB: bad relocation record imported: %d"
msgstr "%p: Fejlagtig relokeringspost importeret: %d"

I think the BFD formatter function is supposed to replace %pB by
something, and later printf presumably replaces %d by a number.

But now, the BFD formatter will likely perform no replacement, whereas
printf reads first a pointer and then a number (probably accessing bad
memory), and tries to format this arbitrary data.

Best regards
Ask


>
> [1] http://translationproject.org/domain/bfd.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]