]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - catgets/catgets.c
i686: Regenerate ulps
[thirdparty/glibc.git] / catgets / catgets.c
index 7ebee2180016fcdb626863bbe261e1c72c6881e9..e65af31b7cc82d0c6b0ec083e21c88275507ca8e 100644 (file)
@@ -1,6 +1,5 @@
-/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper, <drepper@gnu.org>.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -14,9 +13,8 @@
 
    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 <alloca.h>
 #include <errno.h>
 #include <locale.h>
 #include <nl_types.h>
@@ -35,6 +33,7 @@ catopen (const char *cat_name, int flag)
   __nl_catd result;
   const char *env_var = NULL;
   const char *nlspath = NULL;
+  char *tmp = NULL;
 
   if (strchr (cat_name, '/') == NULL)
     {
@@ -54,7 +53,10 @@ catopen (const char *cat_name, int flag)
        {
          /* Append the system dependent directory.  */
          size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
-         char *tmp = alloca (len);
+         tmp = malloc (len);
+
+         if (__glibc_unlikely (tmp == NULL))
+           return (nl_catd) -1;
 
          __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
          nlspath = tmp;
@@ -65,16 +67,18 @@ catopen (const char *cat_name, int flag)
 
   result = (__nl_catd) malloc (sizeof (*result));
   if (result == NULL)
-    /* We cannot get enough memory.  */
-    return (nl_catd) -1;
-
-  if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
+    {
+      /* We cannot get enough memory.  */
+      result = (nl_catd) -1;
+    }
+  else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
     {
       /* Couldn't open the file.  */
       free ((void *) result);
-      return (nl_catd) -1;
+      result = (nl_catd) -1;
     }
 
+  free (tmp);
   return (nl_catd) result;
 }
 
@@ -97,8 +101,8 @@ catgets (nl_catd catalog_desc, int set, int message, const char *string)
   cnt = 0;
   do
     {
-      if (catalog->name_ptr[idx + 0] == (u_int32_t) set
-         && catalog->name_ptr[idx + 1] == (u_int32_t) message)
+      if (catalog->name_ptr[idx + 0] == (uint32_t) set
+         && catalog->name_ptr[idx + 1] == (uint32_t) message)
        return (char *) &catalog->strings[catalog->name_ptr[idx + 2]];
 
       idx += catalog->plane_size * 3;