Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 11 Feb 2004 22:49:57 +0000 (22:49 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 11 Feb 2004 22:49:57 +0000 (22:49 +0000)
2004-02-11  Jakub Jelinek  <jakub@redhat.com>

* posix/regexec.c (check_node_accept_bytes): Return 0 if char_len is 0.
(find_collation_sequence_value): Don't look beyond end of
SYMB_EXTRAMB table.
* posix/Makefile (tests): Add bug-regex23.
(bug-regex23-ENV): New.
* posix/bug-regex23.c: New file.

* include/rpc/rpc.h: Declare thread variables with their correct type.

ChangeLog
posix/Makefile
posix/bug-regex23.c [new file with mode: 0644]
posix/regexec.c

index 1b08828..ceb93bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * posix/regexec.c (check_node_accept_bytes): Return 0 if char_len is 0.
+       (find_collation_sequence_value): Don't look beyond end of
+       SYMB_EXTRAMB table.
+       * posix/Makefile (tests): Add bug-regex23.
+       (bug-regex23-ENV): New.
+       * posix/bug-regex23.c: New file.
+
 2004-02-10  Roland McGrath  <roland@frob.com>
 
        * sysdeps/mach/hurd/times.c (__times): Use union instead of cast.
@@ -81,8 +90,7 @@
 
 2004-02-09  Andreas Schwab  <schwab@suse.de>
 
-       * include/rpc/rpc.h: Declare thread variables with their correct
-       type.
+       * include/rpc/rpc.h: Declare thread variables with their correct type.
        * sunrpc/clnt_perr.c: Don't cast thread variables.
        * sunrpc/clnt_raw.c: Likewise.
        * sunrpc/clnt_simp.c: Likewise.
index bfde636..5a9d7f9 100644 (file)
@@ -79,7 +79,7 @@ tests         := tstgetopt testfnm runtests runptests      \
                   bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
                   bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
                   bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
-                  bug-regex21 bug-regex22 tst-nice tst-nanosleep \
+                  bug-regex21 bug-regex22 bug-regex23 tst-nice tst-nanosleep \
                   transbug tst-rxspencer tst-pcre tst-boost
 ifeq (yes,$(build-shared))
 test-srcs      := globtest
@@ -163,6 +163,7 @@ bug-regex18-ENV = LOCPATH=$(common-objpfx)localedata
 bug-regex19-ENV = LOCPATH=$(common-objpfx)localedata
 bug-regex20-ENV = LOCPATH=$(common-objpfx)localedata
 bug-regex22-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex23-ENV = LOCPATH=$(common-objpfx)localedata
 tst-rxspencer-ARGS = --utf8 rxspencer/tests
 tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata
 tst-pcre-ARGS = PCRE.tests
diff --git a/posix/bug-regex23.c b/posix/bug-regex23.c
new file mode 100644 (file)
index 0000000..61ee4f5
--- /dev/null
@@ -0,0 +1,35 @@
+/* Test we don't segfault on invalid UTF-8 sequence.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <regex.h>
+#include <string.h>
+
+int
+main (void)
+{
+  regex_t r;
+
+  memset (&r, 0, sizeof (r));
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  regcomp (&r, "[-a-z_0-9.]+@[-a-z_0-9.]+", REG_EXTENDED | REG_ICASE);
+  regexec (&r, "\xe7\xb7\x95\xe7\x97", 0, NULL, 0);
+  return 0;
+}
index 32ba80a..c524ce8 100644 (file)
@@ -3666,7 +3666,7 @@ check_node_accept_bytes (dfa, node_idx, input, str_idx)
     }
 
   elem_len = re_string_elem_size_at (input, str_idx);
-  if (elem_len <= 1 && char_len <= 1)
+  if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
     return 0;
 
   if (node->type == COMPLEX_BRACKET)
@@ -3847,8 +3847,10 @@ find_collation_sequence_value (mbs, mbs_len)
       int32_t idx;
       const unsigned char *extra = (const unsigned char *)
        _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+      int32_t extrasize = (const unsigned char *)
+       _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
 
-      for (idx = 0; ;)
+      for (idx = 0; idx < extrasize;)
        {
          int mbs_cnt, found = 0;
          int32_t elem_mbs_len;
@@ -3878,6 +3880,7 @@ find_collation_sequence_value (mbs, mbs_len)
          /* Skip the collation sequence value.  */
          idx += sizeof (uint32_t);
        }
+      return UINT_MAX;
     }
 }
 # endif /* _LIBC */