]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
localedef: check LC_IDENTIFICATION.category values
authorMike Frysinger <vapier@gentoo.org>
Wed, 13 Apr 2016 22:38:56 +0000 (18:38 -0400)
committerMike Frysinger <vapier@gentoo.org>
Fri, 15 Apr 2016 16:44:05 +0000 (12:44 -0400)
Currently localedef accepts any value for the category keyword.  This has
allowed bad values to propagate to the vast majority of locales (~90%).
Add some logic to only accept a few standards.

locale/programs/ld-identification.c
localedata/ChangeLog

index 1e8fa84712ccf237ccf0d8b1760f70b150c0a3a4..84a21acaa731864626d05184da9ac4cb8999a767 100644 (file)
@@ -164,14 +164,45 @@ No definition for %s category found"), "LC_IDENTIFICATION"));
   TEST_ELEM (date);
 
   for (num = 0; num < __LC_LAST; ++num)
-    if (num != LC_ALL && identification->category[num] == NULL)
-      {
-       if (verbose && ! nothing)
-         WITH_CUR_LOCALE (error (0, 0, _("\
+    {
+      /* We don't accept/parse this category, so skip it early.  */
+      if (num == LC_ALL)
+       continue;
+
+      if (identification->category[num] == NULL)
+       {
+         if (verbose && ! nothing)
+           WITH_CUR_LOCALE (error (0, 0, _("\
 %s: no identification for category `%s'"),
-                                 "LC_IDENTIFICATION", category_name[num]));
-       identification->category[num] = "";
-      }
+                                   "LC_IDENTIFICATION", category_name[num]));
+         identification->category[num] = "";
+       }
+      else
+       {
+         /* Only list the standards we care about.  This is based on the
+            ISO 30112 WD10 [2014] standard which supersedes all previous
+            revisions of the ISO 14652 standard.  */
+         static const char * const standards[] =
+           {
+             "posix:1993",
+             "i18n:2004",
+             "i18n:2012",
+           };
+         size_t i;
+         bool matched = false;
+
+         for (i = 0; i < sizeof (standards) / sizeof (standards[0]); ++i)
+           if (strcmp (identification->category[num], standards[i]) == 0)
+             matched = true;
+
+         if (matched != true)
+           WITH_CUR_LOCALE (error (0, 0, _("\
+%s: unknown standard `%s' for category `%s'"),
+                                   "LC_IDENTIFICATION",
+                                   identification->category[num],
+                                   category_name[num]));
+       }
+    }
 }
 
 
index c51e6fcf5695dc0bb972c54579eaf5a26c4586b7..6fbd63d6d1032c2de08eddb8f38ec129c4f380fb 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * locale/programs/ld-identification.c (identification_finish): Check
+       that the values in identification->category are only known.
+
 2016-04-15  Mike Frysinger  <vapier@gentoo.org>
 
        * locales/aa_DJ (LC_IDENTIFICATION): Change all category fields to