[git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-3-g52e1f2e

by Werner Koch cvs at cvs.gnupg.org
Mon Jul 15 16:07:14 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".

The branch, master has been updated
       via  52e1f2e131b422fdb66abeaf4a8f084689b39bf7 (commit)
       via  659389fb01a924f1c2b24f59d2c2d6cccb17ce4e (commit)
      from  670dc6c4a7082370be29861e13310555f62f2b4b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 52e1f2e131b422fdb66abeaf4a8f084689b39bf7
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jul 15 15:31:55 2013 +0200

    w32: Fix corrupted string output.
    
    * src/w32-gettext.c (get_string): Pass the nul of the utf-8 string to
    the conversion function but keep TRANSLEN without the nul.
    --
    
    The bug first occurred on Windows 8 but it is a real thing.  Assuming
    that a malloced buffer is zeroed out is not solid assumptions ;-)

diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index 936cafe..89f505d 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -1617,6 +1617,17 @@ get_string (struct loaded_domain *domain, uint32_t idx,
                 + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
       plen_utf8 = SWAPIT(domain->must_swap, domain->trans_tab[idx].length);
 
+      /* We need to include the nul, so that the utf8->wchar->native
+         conversion chain works correctly and the nul is stored after
+         the conversion. */
+      if (p_utf8[plen_utf8])
+        {
+          trans = "ERROR in MO file"; /* Terminating zero is missing.  */
+          translen = 0;
+          goto leave;
+        }
+      plen_utf8++;
+
       buf = utf8_to_native (p_utf8, plen_utf8, &buflen);
       if (!buf)
         {
@@ -1640,10 +1651,10 @@ get_string (struct loaded_domain *domain, uint32_t idx,
           /* There is not enough space for the translation (or for
              whatever reason an empty string is used): Store it in the
              overflow_space and mark that in the mapped array.
-             Because UTF-8 strings are in general shorter than the
-             Windows 2 byte encodings, we expect that this won't
-             happen too often (if at all) and thus we use a linked
-             list to manage this space. */
+             Because UTF-8 strings are in general longer than the
+             Windows native encoding, we expect that this won't happen
+             too often and thus we use a linked list to manage this
+             space. */
           os = jnlib_malloc (sizeof *os + buflen);
           if (os)
             {
@@ -1662,6 +1673,8 @@ get_string (struct loaded_domain *domain, uint32_t idx,
               translen = 0;
             }
         }
+      if (translen)
+        translen--;  /* TRANSLEN shall be the size without the nul.  */
       jnlib_free (buf);
     }
   else if (domain->mapped[idx] == 1)
@@ -1688,6 +1701,7 @@ get_string (struct loaded_domain *domain, uint32_t idx,
       translen = domain->mapped[idx];
     }
 
+ leave:
   if (use_plural && translen)
     return get_plural (trans, translen, nplural);
   else

commit 659389fb01a924f1c2b24f59d2c2d6cccb17ce4e
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jul 15 13:48:38 2013 +0200

    Remove trailing spaces from w32-gettext.c.
    
    --

diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index fbb256e..936cafe 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -3,17 +3,17 @@
                  2008, 2010 Free Software Foundation, Inc.
 
    This file is part of libgpg-error.
- 
+
    libgpg-error is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public License
    as published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
- 
+
    libgpg-error is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
- 
+
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
@@ -634,8 +634,8 @@ MyCreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode,
 #ifndef SUBLANG_UZBEK_CYRILLIC
 #define SUBLANG_UZBEK_CYRILLIC 0x02
 #endif
- 
-/* Return an XPG style locale name 
+
+/* Return an XPG style locale name
      language[_territory[.codeset]][@modifier].
    Don't even bother determining the codeset; it's not useful in this
    context, because message catalogs are not specific to a single
@@ -1081,7 +1081,7 @@ hash_string (const char *str_param)
 {
   unsigned long int hval, g;
   const char *str = str_param;
-  
+
   hval = 0;
   while (*str != '\0')
     {
@@ -1225,7 +1225,7 @@ free_domain (struct loaded_domain *domain)
   jnlib_free (domain);
 }
 
-  
+
 static struct loaded_domain *
 load_domain (const char *filename)
 {
@@ -1293,7 +1293,7 @@ load_domain (const char *filename)
   domain->data = (char *) data;
   domain->data_native = (char *) data + size;
   domain->must_swap = data->magic != MAGIC;
-  
+
   /* Fill in the information about the available tables.  */
   switch (SWAPIT (domain->must_swap, data->revision))
     {
@@ -1307,7 +1307,7 @@ load_domain (const char *filename)
            that many translations is very unlikely given that GnuPG
            with its very large number of strings has only about 1600
            strings + variants.  */
-        nstrings = SWAPIT (domain->must_swap, data->nstrings); 
+        nstrings = SWAPIT (domain->must_swap, data->nstrings);
         if (nstrings > 65534)
           goto bailout;
         domain->nstrings = nstrings;
@@ -1353,7 +1353,7 @@ utf8_to_wchar (const char *string, size_t length, size_t *retlen)
     return NULL;
 
   nbytes = (size_t)(n+1) * sizeof(*result);
-  if (nbytes / sizeof(*result) != (n+1)) 
+  if (nbytes / sizeof(*result) != (n+1))
     {
       gpg_err_set_errno (ENOMEM);
       return NULL;
@@ -1606,17 +1606,17 @@ get_string (struct loaded_domain *domain, uint32_t idx,
                + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
       translen = SWAPIT(domain->must_swap, domain->trans_tab[idx].length);
     }
-  else if (!domain->mapped[idx]) 
+  else if (!domain->mapped[idx])
     {
       /* Not yet mapped.  Map from utf-8 to native encoding now.  */
       const char *p_utf8;
       size_t plen_utf8, buflen;
       char *buf;
 
-      p_utf8 = (domain->data 
+      p_utf8 = (domain->data
                 + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
       plen_utf8 = SWAPIT(domain->must_swap, domain->trans_tab[idx].length);
-      
+
       buf = utf8_to_native (p_utf8, plen_utf8, &buflen);
       if (!buf)
         {
@@ -1628,7 +1628,7 @@ get_string (struct loaded_domain *domain, uint32_t idx,
           /* Copy into the DATA_NATIVE area. */
           char *p_tmp;
 
-          p_tmp = (domain->data_native 
+          p_tmp = (domain->data_native
                    + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
           memcpy (p_tmp, buf, buflen);
           domain->mapped[idx] = buflen;
@@ -1664,7 +1664,7 @@ get_string (struct loaded_domain *domain, uint32_t idx,
         }
       jnlib_free (buf);
     }
-  else if (domain->mapped[idx] == 1) 
+  else if (domain->mapped[idx] == 1)
     {
       /* The translated string is in the overflow_space. */
       for (os=domain->overflow_space; os; os = os->next)
@@ -1681,8 +1681,8 @@ get_string (struct loaded_domain *domain, uint32_t idx,
           translen = 0;
         }
     }
-  else 
-    { 
+  else
+    {
       trans = (domain->data_native
                + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
       translen = domain->mapped[idx];
@@ -1696,7 +1696,7 @@ get_string (struct loaded_domain *domain, uint32_t idx,
 
 
 static const char *
-do_gettext (const char *domainname, 
+do_gettext (const char *domainname,
             const char *msgid, const char *msgid2, unsigned long nplural)
 {
   struct domainlist_s *dl;
@@ -1704,14 +1704,14 @@ do_gettext (const char *domainname,
   int load_failed;
   uint32_t top, bottom, nstr;
   char *filename;
-  
+
   if (!domainname)
     domainname = current_domainname? current_domainname : "";
 
   /* FIXME: The whole locking stuff is a bit questionable because
      gettext does not claim to be thread-safe.  We need to investigate
      this further.  */
-  
+
   load_failed = 0;
   domain = NULL;
   filename = NULL;
@@ -1763,7 +1763,7 @@ do_gettext (const char *domainname,
           domain = NULL;
         }
     }
-  
+
   if (!domain)
     goto not_found; /* No MO file.  */
 
@@ -1780,7 +1780,7 @@ do_gettext (const char *domainname,
         {
           nstr--;
           if (nstr < domain->nstrings
-              && SWAPIT(domain->must_swap, 
+              && SWAPIT(domain->must_swap,
                         domain->orig_tab[nstr].length) >= len
               && !strcmp (msgid, (domain->data
                                   + SWAPIT(domain->must_swap,
@@ -1803,7 +1803,7 @@ do_gettext (const char *domainname,
   while (bottom < top)
     {
       int cmp_val;
-      
+
       nstr = (bottom + top) / 2;
       cmp_val = strcmp (msgid, (domain->data
                                 + SWAPIT(domain->must_swap,
@@ -1909,10 +1909,10 @@ _gpg_w32_gettext_use_utf8 (int value)
 int
 main (int argc, char **argv)
 {
-  const char atext1[] = 
+  const char atext1[] =
     "Warning: You have entered an insecure passphrase.%%0A"
     "A passphrase should be at least %u character long.";
-  const char atext2[] = 
+  const char atext2[] =
     "Warning: You have entered an insecure passphrase.%%0A"
     "A passphrase should be at least %u characters long.";
 
@@ -1921,7 +1921,7 @@ main (int argc, char **argv)
       argc--;
       argv++;
     }
-  
+
   _gpg_err_w32_bindtextdomain ("gnupg2", "c:/programme/gnu/gnupg/share/locale");
 
   printf ("locale is `%s'\n", _gpg_err_w32_gettext_localename ());

-----------------------------------------------------------------------

Summary of changes:
 src/w32-gettext.c |   74 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 44 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
Error codes used by GnuPG et al.
http://git.gnupg.org




More information about the Gnupg-commits mailing list