]> Savannah Git Hosting - gnulib.git/commitdiff
localename: Add parameter validation.
authorBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 09:48:50 +0000 (10:48 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 18:42:14 +0000 (19:42 +0100)
* lib/localename.c (get_locale_t_name, gl_locale_name_thread_unsafe,
gl_locale_name_thread, gl_locale_name_posix, gl_locale_name): Verify
that the category argument is not LC_ALL.

ChangeLog
lib/localename.c

index 023c1d4d50b4426e1c44ae81adaf2a0476d39c5c..531d5ffa57084bd2e769a37212428d83ade4719c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-15  Bruno Haible  <bruno@clisp.org>
+
+       localename: Add parameter validation.
+       * lib/localename.c (get_locale_t_name, gl_locale_name_thread_unsafe,
+       gl_locale_name_thread, gl_locale_name_posix, gl_locale_name): Verify
+       that the category argument is not LC_ALL.
+
 2024-02-14  Bruno Haible  <bruno@clisp.org>
 
        localename: Notice setlocale() invocations on more platforms.
index 3bfcdabf4fdcabe30ee2c34872a04aeda921e09e..72f773bbed07e803daa97b67217410af18df1357 100644 (file)
@@ -2730,6 +2730,9 @@ struniq (const char *string)
 static const char *
 get_locale_t_name (int category, locale_t locale)
 {
+  if (category == LC_ALL)
+    /* Invalid argument.  */
+    abort ();
   if (locale == LC_GLOBAL_LOCALE)
     {
       /* Query the global locale.  */
@@ -3105,6 +3108,9 @@ static
 const char *
 gl_locale_name_thread_unsafe (int category, _GL_UNUSED const char *categoryname)
 {
+  if (category == LC_ALL)
+    /* Invalid argument.  */
+    abort ();
 # if HAVE_GOOD_USELOCALE
   {
     locale_t thread_locale = uselocale (NULL);
@@ -3282,6 +3288,9 @@ gl_locale_name_thread_unsafe (int category, _GL_UNUSED const char *categoryname)
 const char *
 gl_locale_name_thread (int category, _GL_UNUSED const char *categoryname)
 {
+  if (category == LC_ALL)
+    /* Invalid argument.  */
+    abort ();
 #if HAVE_GOOD_USELOCALE
   const char *name = gl_locale_name_thread_unsafe (category, categoryname);
   if (name != NULL)
@@ -3328,6 +3337,9 @@ gl_locale_name_thread (int category, _GL_UNUSED const char *categoryname)
 const char *
 gl_locale_name_posix (int category, _GL_UNUSED const char *categoryname)
 {
+  if (category == LC_ALL)
+    /* Invalid argument.  */
+    abort ();
 #if defined WINDOWS_NATIVE
   if (LC_MIN <= category && category <= LC_MAX)
     {
@@ -3531,6 +3543,10 @@ gl_locale_name (int category, const char *categoryname)
 {
   const char *retval;
 
+  if (category == LC_ALL)
+    /* Invalid argument.  */
+    abort ();
+
   retval = gl_locale_name_thread (category, categoryname);
   if (retval != NULL)
     return retval;