]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Updated to fedora-glibc-20090424T1908 cvs/fedora-glibc-2_9_90-21
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Apr 2009 19:14:55 +0000 (19:14 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 24 Apr 2009 19:14:55 +0000 (19:14 +0000)
ChangeLog
fedora/branch.mk
fedora/glibc.spec.in
iconv/gconv_simple.c
iconvdata/sjis.c
locale/locarchive.h
locale/programs/locarchive.c
misc/hsearch_r.c
stdio-common/psiginfo.c

index ed8a7becf3cabd81e722e4c153860b0f2074dd89..07881f54eaa65da659a387cd8fcb9d48d6269ab2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2009-04-24  Ulrich Drepper  <drepper@redhat.com>
+
+       [BZ #10093]
+       * iconv/gconv_simple.c (BODY for UTF-8 to INTERNAL): Don't accept
+       UTF-16 surrogates.
+
+       * locale/programs/locarchive.c (enlarge_archive): Conserve address
+       space when temporarily mapping the whole content of the old file.
+
+       [BZ #10100]
+       * misc/hsearch_r.c (hsearch_r): Add back ensurance that hval is
+       not zero.
+
+2009-04-24  Jakub Jelinek  <jakub@redhat.com>
+
+       * iconvdata/sjis.c (BODY): Don't advance inptr before
+       STANDARD_FROM_LOOP_ERR_HANDLER (2) for 2 byte invalid input.
+       Use STANDARD_FROM_LOOP_ERR_HANDLER with 2 instead of 1 for
+       two byte chars.
+
+2009-04-24  Ulrich Drepper  <drepper@redhat.com>
+
+       * locale/locarchive.h (struct locarhandle): Rename len field to
+       mmaped and add new reserved field.
+       * locale/programs/locarchive.c (RESERVE_MMAP_SIZE): Define.
+       (create_archive): Reserve address space and then map file into it.
+       (open_archive): Likewise.
+       (file_data_available_p): New function.
+       (compare_from_file): New function.
+       (close_archive): Adjust to member name changes.
+       (add_locale): Before comparing locale data, check it is mapped.
+       Otherwise fall back to reading from the file.
+
+2009-04-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * stdio-common/psiginfo.c: Include <errno.h>.
+
 2009-04-23  Ulrich Drepper  <drepper@redhat.com>
 
        [BZ #9920]
index f025d9286f729a59f0d0c897f180b9b748725d30..d2d145a22d9fd5ccc677bc4f615bc6ca80754ffd 100644 (file)
@@ -3,5 +3,5 @@ glibc-branch := fedora
 glibc-base := HEAD
 DIST_BRANCH := devel
 COLLECTION := dist-f8
-fedora-sync-date := 2009-04-24 07:47 UTC
-fedora-sync-tag := fedora-glibc-20090424T0747
+fedora-sync-date := 2009-04-24 19:08 UTC
+fedora-sync-tag := fedora-glibc-20090424T1908
index 493e4c605771c977c4c1b232571aeea8f392dbc1..6dbcf139e0bd37aa9c6a10f9bd27ac5aa2451f12 100644 (file)
@@ -19,7 +19,7 @@
 Summary: The GNU libc libraries
 Name: glibc
 Version: @glibcversion@
-Release: 20
+Release: 21
 # GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
 # Things that are linked directly into dynamically linked programs
 # and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
@@ -1009,6 +1009,12 @@ rm -f *.filelist*
 %endif
 
 %changelog
+* Fri Apr 24 2009 Jakub Jelinek <jakub@redhat.com> 2.9.90-21
+- update from trunk
+  - fix localedef
+  - fix SHIFT_JIS iconv EILSEQ handling (#497267)
+  - misc fixes (BZ#10093, BZ#10100)
+
 * Fri Apr 24 2009 Jakub Jelinek <jakub@redhat.com> 2.9.90-20
 - update from trunk
   - fix p{read,write}v{,64} (#497429, #497434)
index 5cf3237abb964704f9b12d3806b1b14f8cf59c62..e34f3770ad90c790a6556c44d65342a8cde0196c 100644 (file)
@@ -1,5 +1,5 @@
 /* Simple transformations functions.
-   Copyright (C) 1997-2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1997-2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -1037,7 +1037,9 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
        /* If i < cnt, some trail byte was not >= 0x80, < 0xc0.               \
           If cnt > 2 and ch < 2^(5*cnt-4), the wide character ch could       \
           have been represented with fewer than cnt bytes.  */               \
-       if (i < cnt || (cnt > 2 && (ch >> (5 * cnt - 4)) == 0))               \
+       if (i < cnt || (cnt > 2 && (ch >> (5 * cnt - 4)) == 0)                \
+           /* Do not accept UTF-16 surrogates.  */                           \
+           || (ch >= 0xd800 && ch <= 0xdfff))                                \
          {                                                                   \
            /* This is an illegal encoding.  */                               \
            goto errout;                                                      \
index 4561779d44ec36c27b0161d3a84f2cca427ba519..f907615a21f4710df9a38eb6300e880339092050 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for SJIS handling.
-   Copyright (C) 1997-2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1997-2001, 2002, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -4372,15 +4372,19 @@ static const char from_ucs4_extra[0x100][2] =
                                                                              \
        ch2 = inptr[1];                                                       \
        idx = ch * 256 + ch2;                                                 \
-       if (__builtin_expect (ch2 < 0x40, 0)                                  \
-           || (__builtin_expect (idx > 0x84be, 0) && idx < 0x889f)           \
-           || (__builtin_expect (idx > 0x88fc, 0) && idx < 0x8940)           \
-           || (__builtin_expect (idx > 0x9ffc, 0) && idx < 0xe040)           \
-           || __builtin_expect (idx > 0xeaa4, 0))                            \
+       if (__builtin_expect (ch2 < 0x40, 0))                                 \
          {                                                                   \
            /* This is illegal.  */                                           \
            STANDARD_FROM_LOOP_ERR_HANDLER (1);                               \
          }                                                                   \
+       else if ((__builtin_expect (idx > 0x84be && idx < 0x889f, 0))         \
+                || (__builtin_expect (idx > 0x88fc && idx < 0x8940, 0))      \
+                || (__builtin_expect (idx > 0x9ffc && idx < 0xe040, 0))      \
+                || __builtin_expect (idx > 0xeaa4, 0))                       \
+         {                                                                   \
+           /* This is illegal.  */                                           \
+           STANDARD_FROM_LOOP_ERR_HANDLER (2);                               \
+         }                                                                   \
        else                                                                  \
          {                                                                   \
            /* We could pack the data a bit more dense.  The second           \
@@ -4395,13 +4399,13 @@ static const char from_ucs4_extra[0x100][2] =
            else                                                              \
              ch = cjk_block4[(ch - 0xe0) * 192 + ch2 - 0x40];                \
                                                                              \
-           inptr += 2;                                                       \
-         }                                                                   \
+           if (__builtin_expect (ch == 0, 0))                                \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               STANDARD_FROM_LOOP_ERR_HANDLER (2);                           \
+             }                                                               \
                                                                              \
-       if (__builtin_expect (ch == 0, 0))                                    \
-         {                                                                   \
-           /* This is an illegal character.  */                              \
-           STANDARD_FROM_LOOP_ERR_HANDLER (2);                               \
+           inptr += 2;                                                       \
          }                                                                   \
       }                                                                              \
                                                                              \
index e94bc2b480f6fdc9cbbf87239aecbbbf38f33513..eb3353d3166a0c0753303c9e319215a091465557 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for locale archive handling.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -83,7 +83,8 @@ struct locarhandle
 {
   int fd;
   void *addr;
-  size_t len;
+  size_t mmaped;
+  size_t reserved;
 };
 
 
index e6f7f7fa487e8252abf58474e92d242d2cd98c73..e2ccda01b74d6d6ece745c17df945b77ebff1481 100644 (file)
@@ -71,6 +71,10 @@ static const char *locnames[] =
 #define INITIAL_NUM_SUMS       2000
 
 
+/* Size of the reserved address space area.  */
+#define RESERVE_MMAP_SIZE      512 * 1024 * 1024
+
+
 static void
 create_archive (const char *archivefname, struct locarhandle *ah)
 {
@@ -125,8 +129,22 @@ create_archive (const char *archivefname, struct locarhandle *ah)
       error (EXIT_FAILURE, errval, _("cannot resize archive file"));
     }
 
+  /* To prepare for enlargements of the mmaped area reserve some
+     address space.  */
+  size_t reserved = RESERVE_MMAP_SIZE;
+  int xflags = 0;
+  if (total < reserved
+      && ((p = mmap64 (NULL, reserved, PROT_NONE, MAP_ANON, -1, 0))
+         != MAP_FAILED))
+    xflags = MAP_FIXED;
+  else
+    {
+      p = NULL;
+      reserved = total;
+    }
+
   /* Map the header and all the administration data structures.  */
-  p = mmap64 (NULL, total, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0);
   if (p == MAP_FAILED)
     {
       int errval = errno;
@@ -170,7 +188,8 @@ create_archive (const char *archivefname, struct locarhandle *ah)
 
   ah->fd = fd;
   ah->addr = p;
-  ah->len = total;
+  ah->mmaped = total;
+  ah->reserved = reserved;
 }
 
 
@@ -226,6 +245,45 @@ void add_alias (struct locarhandle *ah, const char *alias,
                bool replace, const char *oldname,
                uint32_t *locrec_offset_p);
 
+
+static bool
+file_data_available_p (struct locarhandle *ah, uint32_t offset, uint32_t size)
+{
+  if (offset < ah->mmaped && offset + size <= ah->mmaped)
+    return true;
+
+  struct stat64 st;
+  if (fstat64 (ah->fd, &st) != 0)
+    return false;
+
+  if (st.st_size > ah->reserved)
+    return false;
+
+  void *p = mremap (ah->addr, ah->mmaped, st.st_size,
+                   MREMAP_FIXED | MREMAP_MAYMOVE, ah->addr);
+  if (p == MAP_FAILED)
+    return false;
+
+  ah->mmaped = st.st_size;
+  return true;
+}
+
+
+static int
+compare_from_file (struct locarhandle *ah, void *p1, uint32_t offset2,
+                  uint32_t size)
+{
+  void *p2 = xmalloc (size);
+  if (pread (ah->fd, p2, size, offset2) != size)
+    WITH_CUR_LOCALE (error (4, errno,
+                           _("cannot read data from locale archive")));
+
+  int res = memcmp (p1, p2, size);
+  free (p2);
+  return res;
+}
+
+
 static void
 enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
 {
@@ -249,11 +307,23 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
 
   /* Not all of the old file has to be mapped.  Change this now this
      we will have to access the whole content.  */
-  if (fstat64 (ah->fd, &st) != 0
-      || (ah->addr = mmap64 (NULL, st.st_size, PROT_READ | PROT_WRITE,
-                            MAP_SHARED, ah->fd, 0)) == MAP_FAILED)
+  if (fstat64 (ah->fd, &st) != 0)
+  enomap:
     error (EXIT_FAILURE, errno, _("cannot map locale archive file"));
-  ah->len = st.st_size;
+
+  if (st.st_size < ah->reserved)
+    ah->addr = mremap (ah->addr, ah->mmaped, st.st_size,
+                      MREMAP_MAYMOVE | MREMAP_FIXED, ah->addr);
+  else
+    {
+      munmap (ah->addr, ah->reserved);
+      ah->addr = mmap64 (NULL, st.st_size, PROT_READ | PROT_WRITE,
+                        MAP_SHARED, ah->fd, 0);
+      ah->reserved = st.st_size;
+    }
+  if (ah->addr == MAP_FAILED)
+    goto enomap;
+  ah->mmaped = st.st_size;
 
   /* Create a temporary file in the correct directory.  */
   fd = mkstemp (fname);
@@ -331,9 +401,10 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
       error (EXIT_FAILURE, errval, _("cannot lock new archive"));
     }
 
-  new_ah.len = total;
+  new_ah.mmaped = total;
   new_ah.addr = p;
   new_ah.fd = fd;
+  new_ah.reserved = total;
 
   /* Walk through the hash name hash table to find out what data is
      still referenced and transfer it into the new file.  */
@@ -514,18 +585,33 @@ open_archive (struct locarhandle *ah, bool readonly)
     }
 
   ah->fd = fd;
-  ah->len = (head.sumhash_offset
-            + head.sumhash_size * sizeof (struct sumhashent));
+  ah->mmaped = st.st_size;
+
+  /* To prepare for enlargements of the mmaped area reserve some
+     address space.  */
+  size_t reserved = RESERVE_MMAP_SIZE;
+  int xflags = 0;
+  void *p;
+  if (st.st_size < reserved
+      && ((p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_ANON, -1, 0))
+         != MAP_FAILED))
+    xflags = MAP_FIXED;
+  else
+    {
+      p = NULL;
+      reserved = st.st_size;
+    }
 
   /* Map the entire file.  We might need to compare the category data
      in the file with the newly added data.  */
-  ah->addr = mmap64 (NULL, st.st_size, PROT_READ | (readonly ? 0 : PROT_WRITE),
-                    MAP_SHARED, fd, 0);
+  ah->addr = mmap64 (p, st.st_size, PROT_READ | (readonly ? 0 : PROT_WRITE),
+                    MAP_SHARED | xflags, fd, 0);
   if (ah->addr == MAP_FAILED)
     {
       (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead));
       error (EXIT_FAILURE, errno, _("cannot map archive header"));
     }
+  ah->reserved = reserved;
 }
 
 
@@ -534,7 +620,7 @@ close_archive (struct locarhandle *ah)
 {
   if (ah->fd != -1)
     {
-      munmap (ah->addr, ah->len);
+      munmap (ah->addr, ah->reserved);
       close (ah->fd);
     }
 }
@@ -777,9 +863,18 @@ add_locale (struct locarhandle *ah,
 
                if (iloc != head->locrectab_used
                    && data[cnt].size == locrecent[iloc].record[cnt].len
-                   && memcmp (data[cnt].addr,
-                              (char *) ah->addr + sumhashtab[idx].file_offset,
-                              data[cnt].size) == 0)
+                   /* We have to compare the content.  Either we can
+                      have the data mmaped or we have to read from
+                      the file.  */
+                   && (file_data_available_p (ah, sumhashtab[idx].file_offset,
+                                              data[cnt].size)
+                       ? memcmp (data[cnt].addr,
+                                 (char *) ah->addr
+                                 + sumhashtab[idx].file_offset,
+                                 data[cnt].size) == 0
+                       : compare_from_file (ah, data[cnt].addr,
+                                            sumhashtab[idx].file_offset,
+                                            data[cnt].size) == 0))
                  {
                    /* Found it.  */
                    file_offsets[cnt] = sumhashtab[idx].file_offset;
index 6e32afc43e2dde7f29f991ac4ea434c3526af778..73b95650304062d22e91941f56ec88263afe706b 100644 (file)
@@ -157,6 +157,8 @@ hsearch_r (item, action, retval, htab)
       hval <<= 4;
       hval += item.key[count];
     }
+  if (hval == 0)
+    ++hval;
 
   /* First hash function: simply take the modul but prevent zero. */
   idx = hval % htab->size + 1;
index 9fc2911fd182c2251ab24bcaeacb46e49eb051e8..e089fcaa42ce8544ad3c347e74a43334df6fef9b 100644 (file)
@@ -16,6 +16,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <libintl.h>
 #include <signal.h>
 #include <stdint.h>