public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "jim at meyering dot net" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs-regex@sources.redhat.com
Subject: [Bug regex/11244] New: re_compiler_pattern fails to diagnose [b-a] as an invalid range
Date: Wed, 03 Feb 2010 16:47:00 -0000	[thread overview]
Message-ID: <20100203164729.11244.jim@meyering.net> (raw)

tested on rawhide, with glibc-2.11.90-10.x86_64:

$ cat regex-check.c
#include <config.h>
#include <limits.h>
#include <regex.h>
#include <string.h>

int
main (int argc, char **argv)
{
  char *regexp = (2 <= argc ? argv[1] : "a[b-a]");
  struct re_pattern_buffer regex;
  /* Ensure that [b-a] is diagnosed as invalid. */
  re_set_syntax (RE_SYNTAX_POSIX_EGREP);
  memset (&regex, 0, sizeof regex);
  const char *s = re_compile_pattern (regexp, strlen (regexp), &regex);
  return s == NULL;
}
$ echo '#define _GNU_SOURCE 1' > config.h
$ gcc -g -Wall -W -Wextra regex-check.c -I.
$ ./a.out
[Exit 1]

It looks like the code intends to diagnose that condition with REG_ERANGE,
but something is not working:

      start_collseq = lookup_collation_sequence_value (start_elem);
      end_collseq = lookup_collation_sequence_value (end_elem);
      /* Check start/end collation sequence values.  */
      if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
	return REG_ECOLLATE;
      if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
	return REG_ERANGE;

-- 
           Summary: re_compiler_pattern fails to diagnose [b-a] as an
                    invalid range
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: regex
        AssignedTo: drepper at redhat dot com
        ReportedBy: jim at meyering dot net
                CC: glibc-bugs-regex at sources dot redhat dot com,glibc-
                    bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11244

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2010-02-03 16:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03 16:47 jim at meyering dot net [this message]
2010-02-03 17:13 ` [Bug regex/11244] " schwab at linux-m68k dot org
2010-02-03 17:47 ` jim at meyering dot net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100203164729.11244.jim@meyering.net \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs-regex@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).