]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - locale/loadarchive.c
Fix locale/tst-locale-locpath cross-testing when sshd sets LANG.
[thirdparty/glibc.git] / locale / loadarchive.c
index 744b61f605014dc7e39f1de17bc11b8f6d3673b3..ba0fe45648e111022c9b62dd82d04554d300cd54 100644 (file)
@@ -1,5 +1,5 @@
 /* Code to load locale data from the locale archive file.
-   Copyright (C) 2002-2015 Free Software Foundation, Inc.
+   Copyright (C) 2002-2020 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
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <locale.h>
 #include <stddef.h>
@@ -130,7 +130,6 @@ calculate_head_size (const struct locarhead *h)
    structure.  If successful, sets *NAMEP to point directly into the mapped
    archive string table; that way, the next call can short-circuit strcmp.  */
 struct __locale_data *
-internal_function
 _nl_load_locale_from_archive (int category, const char **namep)
 {
   const char *name = *namep;
@@ -203,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
       archmapped = &headmap;
 
       /* The archive has never been opened.  */
-      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+      fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
       if (fd < 0)
        /* Cannot open the archive, for whatever reason.  */
        return NULL;
@@ -213,7 +212,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
          /* stat failed, very strange.  */
        close_and_out:
          if (fd >= 0)
-           close_not_cancel_no_status (fd);
+           __close_nocancel_nostatus (fd);
          return NULL;
        }
 
@@ -253,7 +252,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
        {
          /* We've mapped the whole file already, so we can be
             sure we won't need this file descriptor later.  */
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
          fd = -1;
        }
 
@@ -275,7 +274,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
                                        + head->namehash_offset);
 
   /* Avoid division by 0 if the file is corrupted.  */
-  if (__glibc_unlikely (head->namehash_size == 0))
+  if (__glibc_unlikely (head->namehash_size <= 2))
     goto close_and_out;
 
   idx = hval % head->namehash_size;
@@ -398,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
          if (fd == -1)
            {
              struct stat64 st;
-             fd = open_not_cancel_2 (archfname,
-                                     O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+             fd = __open_nocancel (archfname,
+                                   O_RDONLY|O_LARGEFILE|O_CLOEXEC);
              if (fd == -1)
                /* Cannot open the archive, for whatever reason.  */
                return NULL;
@@ -452,7 +451,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
 
   /* We don't need the file descriptor any longer.  */
   if (fd >= 0)
-    close_not_cancel_no_status (fd);
+    __close_nocancel_nostatus (fd);
   fd = -1;
 
   /* We succeeded in mapping all the necessary regions of the archive.
@@ -462,7 +461,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
   if (__glibc_unlikely (lia == NULL))
     return NULL;
 
-  lia->name = strdup (*namep);
+  lia->name = __strdup (*namep);
   if (__glibc_unlikely (lia->name == NULL))
     {
       free (lia);