This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] localedef: check LC_IDENTIFICATION.category values
- From: keld at keldix dot com
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-alpha at sourceware dot org, carlos at redhat dot com
- Date: Thu, 14 Apr 2016 10:59:19 +0200
- Subject: Re: [PATCH] localedef: check LC_IDENTIFICATION.category values
- Authentication-results: sourceware.org; auth=none
- References: <570E96AE dot 3070209 at redhat dot com> <1460587532-5278-1-git-send-email-vapier at gentoo dot org>
Please also allow ISO 30112 categories.
best regards
keld
On Wed, Apr 13, 2016 at 06:45:32PM -0400, Mike Frysinger wrote:
> 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 the 1993 POSIX and 2002 ISO-14652 standards.
>
> 2016-04-13 Mike Frysinger <vapier@gentoo.org>
>
> * locale/programs/ld-identification.c (identification_finish): Check
> that the values in identification->category are only posix:1993 or
> i18n:2002.
> ---
> locale/programs/ld-identification.c | 42 ++++++++++++++++++++++++++++++-------
> 1 file changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/locale/programs/ld-identification.c b/locale/programs/ld-identification.c
> index 1e8fa84..eccb388 100644
> --- a/locale/programs/ld-identification.c
> +++ b/locale/programs/ld-identification.c
> @@ -164,14 +164,42 @@ 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. */
> + static const char * const standards[] =
> + {
> + "posix:1993",
> + "i18n:2002",
> + };
> + 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]));
> + }
> + }
> }
>
>
> --
> 2.7.4