public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug locale/28255] New: A locale with zero collation rules cause fnmatch, regexec, and regcomp failures.
@ 2021-08-20 22:05 carlos at redhat dot com
  2021-09-16 20:18 ` [Bug locale/28255] " fweimer at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: carlos at redhat dot com @ 2021-08-20 22:05 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28255

            Bug ID: 28255
           Summary: A locale with zero collation rules cause fnmatch,
                    regexec, and regcomp failures.
           Product: glibc
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: locale
          Assignee: unassigned at sourceware dot org
          Reporter: carlos at redhat dot com
  Target Milestone: ---

It should be possible to build a locale with zero collation rules. Such a
locale would fall back to using strcmp and wcscmp during collation.

Such a collation, one with zero collation rules, would also lack any data for
_NL_COLLATE_COLLSEQMB, and _NL_COLLATE_COLLSEQWC. Any code using these tables
must be gated on nrules != 0.

However, as-of today, the only such locale in glibc was the builtin C locale,
and even though it has 0 collation rules, it has identity tables for
_NL_COLLATE_COLLSEQMB, and _NL_COLLATE_COLLSEQWC.

These identity tables are used unconditionally by fnmatch, regexec, and
regcomp, which means that when you don't generate them, the code does not
properly handle regular expressions.

The fix for this is quite extensive, and I didn't want to include it in glibc
2.34, but the fixes are present here in v4 of my C.UTF-8 patch series:
https://patchwork.sourceware.org/project/glibc/patch/20210729063515.1541388-2-carlos@redhat.com/

The fix is also insufficient because statically linked applications would not
have the fixes, so we must still keep the identity tables to allow static
applications to continue working with the new binary locales (until we manage
to make C.UTF-8 builtin).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug locale/28255] A locale with zero collation rules cause fnmatch,  regexec, and regcomp failures.
  2021-08-20 22:05 [Bug locale/28255] New: A locale with zero collation rules cause fnmatch, regexec, and regcomp failures carlos at redhat dot com
@ 2021-09-16 20:18 ` fweimer at redhat dot com
  2021-12-16 22:32 ` carlos at redhat dot com
  2021-12-16 22:32 ` carlos at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2021-09-16 20:18 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28255

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-
                 CC|                            |fweimer at redhat dot com
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |2.35
         Resolution|---                         |FIXED

--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
Fixed for glibc 2.35 via:

commit f5117c6504888fab5423282a4607c552b90fd3f9
Author: Carlos O'Donell <carlos@redhat.com>
Date:   Thu Jul 29 22:45:39 2021 -0400

    Add 'codepoint_collation' support for LC_COLLATE.

    Support a new directive 'codepoint_collation' in the LC_COLLATE
    section of a locale source file. This new directive causes all
    collation rules to be dropped and instead STRCMP (strcmp or
    wcscmp) is used for collation of the input character set. This
    is required to allow for a C.UTF-8 that contains zero collation
    rules (minimal size) and sorts using code point sorting.

    To date the only implementation of a locale with zero collation
    rules is the C/POSIX locale. The C/POSIX locale provides
    identity tables for _NL_COLLATE_COLLSEQMB and
    _NL_COLLATE_COLLSEQWC that map to ASCII even though it has zero
    rules. This has lead to existing fnmatch, regexec, and regcomp
    implementations that require these tables. It is not correct
    to use these tables when nrules == 0, but the conservative fix
    is to provide these tables when nrules == 0. This assures that
    existing static applications using a new C.UTF-8 locale with
    'codepoint_collation' at least have functional range expressions
    with ASCII e.g. [0-9] or [a-z]. Such static applications would
    not have the fixes to fnmatch, regexec and regcomp that avoid
    the use of the tables when nrules == 0. Future fixes to fnmatch,
    regexec, and regcomp would allow range expressions to use the
    full set of code points for such ranges.

    Tested on x86_64 and i686 without regression.

    Reviewed-by: Florian Weimer <fweimer@redhat.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug locale/28255] A locale with zero collation rules cause fnmatch,  regexec, and regcomp failures.
  2021-08-20 22:05 [Bug locale/28255] New: A locale with zero collation rules cause fnmatch, regexec, and regcomp failures carlos at redhat dot com
  2021-09-16 20:18 ` [Bug locale/28255] " fweimer at redhat dot com
@ 2021-12-16 22:32 ` carlos at redhat dot com
  2021-12-16 22:32 ` carlos at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: carlos at redhat dot com @ 2021-12-16 22:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28255

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #2 from Carlos O'Donell <carlos at redhat dot com> ---
The commit f5117c6504888fab5423282a4607c552b90fd3f9 does not solve this issue.

The fix for this issue is to cleanup the regular expression range code:
https://sourceware.org/pipermail/libc-alpha/2021-July/129588.html

We dropped these fixes in the final C.UTF-8 implementation because it was
possible to implement C.UTF-8 without fixing regexec et. al.

If we fix the regular expression range handling code it will then work for all
code point ranges correctly e.g. use the wide character values as range end
points.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug locale/28255] A locale with zero collation rules cause fnmatch,  regexec, and regcomp failures.
  2021-08-20 22:05 [Bug locale/28255] New: A locale with zero collation rules cause fnmatch, regexec, and regcomp failures carlos at redhat dot com
  2021-09-16 20:18 ` [Bug locale/28255] " fweimer at redhat dot com
  2021-12-16 22:32 ` carlos at redhat dot com
@ 2021-12-16 22:32 ` carlos at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: carlos at redhat dot com @ 2021-12-16 22:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28255

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
As of today C.UTF-8 is limited to ASCII ranges because of this fix it missing.
And all static applications until recompiled will be limited to ASCII ranges.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-16 22:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 22:05 [Bug locale/28255] New: A locale with zero collation rules cause fnmatch, regexec, and regcomp failures carlos at redhat dot com
2021-09-16 20:18 ` [Bug locale/28255] " fweimer at redhat dot com
2021-12-16 22:32 ` carlos at redhat dot com
2021-12-16 22:32 ` carlos at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).