/* 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
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>
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;
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;
/* stat failed, very strange. */
close_and_out:
if (fd >= 0)
- close_not_cancel_no_status (fd);
+ __close_nocancel_nostatus (fd);
return NULL;
}
{
/* 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;
}
+ 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;
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;
/* 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.
if (__glibc_unlikely (lia == NULL))
return NULL;
- lia->name = strdup (*namep);
+ lia->name = __strdup (*namep);
if (__glibc_unlikely (lia->name == NULL))
{
free (lia);