Commit Graph

125 Commits

Author SHA1 Message Date
Paul Eggert ef202e530c regex: fix storage-exhaustion error
[BZ #18040]
* posix/regexec.c (get_subexp):
Do not continue if storage is exhausted.
2018-12-16 07:08:29 -08:00
Assaf Gordon 077caf61d8 regex: fix heap-use-after-free error
[BZ #18040]
Problem reported by Saito Takaaki <tails.saito@gmail.com> in
https://debbugs.gnu.org/32592
Call stack get_subexp->get_subexp_sub->clean_state_log_if_needed may
call extend_buffers which reallocates the re_string_t internal buffer.
Local variable 'buf' was not updated in such case, resulting in
use-after-free.
* posix/regexec.c (get_subexp): Update 'buf' after call to
get_subexp_sub.
2018-12-16 07:08:29 -08:00
Paul Eggert f4efbdfb44 regex: __builtin_expect → __glibc_unlikely
[BZ#23744]
This refactoring was prompted by a problem when the regex code is
used as part of Gnulib and when the builder’s compiler does not grok
__builtin_expect.  Problem reported for Gawk by Nelson H.F. Beebe in:
https://lists.gnu.org/r/bug-gnulib/2018-09/msg00137.html
Although this refactoring does not fix the problem directly,
we might as well have Gawk use the now-preferred glibc style for when
__builtin_expect is unavailable.
* posix/regex_internal.h (BE): Remove.
All uses replaced by __glibc_unlikely or __glibc_likely.
2018-10-14 23:36:55 -05:00
Florian Weimer 7b2f4cedf0 regexec: Fix off-by-one bug in weight comparison [BZ #23036]
Each weight is prefixed by its length, and the length does not include
itself in the count.  This can be seen clearly from the find_idx
function in string/strxfrm_l.c, for example.  The old code behaved as if
the length itself counted, thus comparing an additional byte after the
weight, leading to spurious comparison failures and incorrect further
partitioning of character equivalence classes.
2018-07-10 11:18:26 +02:00
Adhemerval Zanella eb04c21373 posix: Sync gnulib regex implementation
This patch syncs the regex implementation with gnulib (commit 0ee5212).
Only two changes in GLIBC regex testing are required:

  1. posix/bug-regex28.c: as previously discussed [1] the change of
     expected results on the pattern should be safe.

  2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that
     the \1 doesn't mean anything) and although current GLIBC accepts
     it has undefined behavior.  This patch removes the specific test.

This sync contains some patches from thread 'Regex: Make libc regex
more usable outside GLIBC.' [2] which have been pushed upstream in
gnulib.  This patches also fixes some regex issues (BZ #23233,
BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for
both #23233 and #13762 because I couldn't think a simple way to
trigger the expected failure path to trigger them.

Checked on x86_64-linux-gnu and i686-linux-gnu.

	[BZ #23233]
	[BZ #21163]
	[BZ #18986]
	[BZ #13762]
	* posix/Makefile (tests): Add bug-regex37 and bug-regex38.
	* posix/PCRE.tests: Remove invalid test.
	* posix/bug-regex28.c: Fix expected values for used syntax.
	* posix/bug-regex37.c: New file.
	* posix/bug-regex38.c: Likewise.
	* posix/regcomp.c: Sync with gnulib.
	* posix/regex.c: Likewise.
	* posix/regex.h: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regex_internal.h: Likewise.
	* posix/regexec.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html
[2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html
2018-07-04 09:54:45 -03:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Eric Blake ed8ae46bed Avoid gcc warnings on cygwin
* posix/regex_internal.c (re_string_reconstruct) [!RE_ENABLE_I18N]:
* posix/regexec.c (check_arrival_add_next_nodes) [!RE_ENABLE_I18N]:
Avoid unused variable.
2017-12-22 08:01:27 -08:00
Arnold Robbins 5069ff3284 regex: Fix spelling in comments.
Fix the spelling in various comments throughout the
regex implementation. These changes are also present
in gnulib and will be integrated there also, see:
https://sourceware.org/ml/libc-alpha/2017-12/msg00688.html
2017-12-19 19:28:21 -08:00
H.J. Lu b68f862056 Hide internal regex functions [BZ #18822]
Hide internal regex functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/regex.h (__re_compile_fastmap): Add attribute_hidden.
	(__regcomp): Add libc_hidden_proto.
	(__regexec): Likewise.
	(__regfree): Likewise.
	* posix/regcomp.c (__regcomp): Add libc_hidden_def.
	(__regfree): Likewise.
	* posix/regexec.c (__regexec): Likewise.
2017-10-01 15:53:15 -07:00
Florian Weimer b41bd5bc83 posix: Remove internal_function attribute 2017-08-31 18:52:00 +02:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers 85231522bb Convert a few more function definitions to prototype style.
This patch converts a few more function definitions in glibc from
old-style K&R to prototype style.  This is sufficient to build and
test on x86_64 and x86 with -Wold-style-definition (I'll test on some
more architectures before proposing the actual addition of
-Wold-style-definition).

Tested for x86_64 and x86 with -Wold-style-definition in use
(testsuite - this patch affects files containing assertions).

	* io/fts.c (fts_open): Convert to prototype-style function
	definition.
	* malloc/mcheck.c (mcheck): Likewise.
	(mcheck_pedantic): Likewise.
	* posix/regexec.c (re_search_2_stub): Likewise.  Use
	internal_function.
	(re_search_internal): Likewise.
	* resolv/res_init.c [RESOLVSORT] (net_mask): Convert to
	prototype-style function definition.
	* sunrpc/clnt_udp.c (clntudp_call): Likewise.
	* sunrpc/pmap_rmt.c (clnt_broadcast): Likewise.
	* sunrpc/rpcsvc/rusers.x (xdr_utmp): Likewise.
	(xdr_utmpptr): Likewise.
	(xdr_utmparr): Likewise.
	(xdr_utmpidle): Likewise.
	(xdr_utmpidleptr): Likewise.
	(xdr_utmpidlearr): Likewise.
2015-10-21 11:57:23 +00:00
Joseph Myers 80d9be8122 Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style.  These changes
were made manually.  This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.

Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.

Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).

	* debug/fortify_fail.c (__fortify_fail): Convert to
	prototype-style function definition.  Use internal_function.
	* libio/genops.c (save_for_backup): Convert to prototype-style
	function definition.
	* libio/wgenops.c (save_for_wbackup): Likewise.
	* login/grantpt.c (grantpt): Likewise.
	* login/ptsname.c (ptsname): Likewise.
	(__ptsname_r): Likewise.
	* login/unlockpt.c (unlockpt): Likewise.
	* mach/msgserver.c (__mach_msg_server): Likewise.
	* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
	(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
	* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
	* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
	Likewise.
	* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise.  Use
	internal_function.
	* nptl/pthread_atfork.c (__pthread_atfork): Convert to
	prototype-style function definition.
	* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
	[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
	(__pthread_create_2_0): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/register-atfork.c (__register_atfork): Likewise.
	* posix/glob.c (glob): Likewise.
	* posix/regcomp.c (re_comp): Likewise.
	* posix/regexec.c (re_exec): Likewise.
	* stdlib/add_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/cmp.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divrem.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/lshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/rshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
	function definition.
	(STRTOF): Likewise.
	* stdlib/strtod_l.c (__STRTOF): Likewise.
	* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
	* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
	(__strtol_l): Likewise.
	* stdlib/sub_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* string/memrchr.c (MEMRCHR): Convert to prototype-style function
	definition.
	* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strcasecmp): Convert to prototype-style function definition.
	* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strncasecmp): Convert to prototype-style function definition.
	* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
	* sunrpc/xdr.c (xdr_union): Likewise.
	* sunrpc/xdr_array.c (xdr_array): Likewise.
	* sunrpc/xdr_ref.c (xdr_reference): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
	Likewise.
	* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
	(LOCALE_PARAM_PROTO): Likewise.
	[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
	argument type.
	(ut_argument_spec): Remove macro.
	(ut_argument_spec_iso): Rename to ut_argument_spec.
	(memcpy_lowcase): Use LOCALE_PARAM in declaration.  Convert to
	prototype-style function definition.
	(memcpy_uppcase): Likewise.
	(__strftime_internal): Likewise.
	(my_strftime): Likewise.
	* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
	(LOCALE_PARAM_DECL): Likewise.
	[_LIBC] (LOCALE_PARAM): Include argument type.
	(__strptime_internal): Convert to prototype-style function
	definition.
	(strptime): Likewise.
	* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcscasecmp): Convert to prototype-style function definition.
	* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00
Joseph Myers 9dd346ff43 Convert 113 more function definitions to prototype style (files with assertions).
This mostly automatically-generated patch converts 113 function
definitions in glibc from old-style K&R to prototype-style.  Following
my other recent such patches, this one deals with the case of function
definitions in files that either contain assertions or where grep
suggested they might contain assertions - and thus where it isn't
possible to use a simple object code comparison as a sanity check on
the correctness of the patch, because line numbers are changed.

A few such automatically-generated changes needed to be supplemented
by manual changes for the result to compile.  openat64 had a prototype
declaration with "..." but an old-style definition in
sysdeps/unix/sysv/linux/dl-openat64.c, and "..." needed adding to the
generated prototype in the definition (I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68024> for diagnosing
such cases in GCC; the old state was undefined behavior not requiring
a diagnostic, but one seems a good idea).  In addition, as Florian has
noted regparm attribute mismatches between declaration and definition
are only diagnosed for prototype definitions, and five functions
needed internal_function added to their definitions (in the case of
__pthread_mutex_cond_lock, via the macro definition of
__pthread_mutex_lock) to compile on i386.

After this patch is in, remaining old-style definitions are probably
most readily fixed manually before we can turn on
-Wold-style-definition for all builds.

Tested for x86_64 and x86 (testsuite).

	* crypt/md5-crypt.c (__md5_crypt_r): Convert to prototype-style
	function definition.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.
	* debug/backtracesyms.c (__backtrace_symbols): Likewise.
	* elf/dl-minimal.c (_itoa): Likewise.
	* hurd/hurdmalloc.c (malloc): Likewise.
	(free): Likewise.
	(realloc): Likewise.
	* inet/inet6_option.c (inet6_option_space): Likewise.
	(inet6_option_init): Likewise.
	(inet6_option_append): Likewise.
	(inet6_option_alloc): Likewise.
	(inet6_option_next): Likewise.
	(inet6_option_find): Likewise.
	* io/ftw.c (FTW_NAME): Likewise.
	(NFTW_NAME): Likewise.
	(NFTW_NEW_NAME): Likewise.
	(NFTW_OLD_NAME): Likewise.
	* libio/iofwide.c (_IO_fwide): Likewise.
	* libio/strops.c (_IO_str_init_static_internal): Likewise.
	(_IO_str_init_static): Likewise.
	(_IO_str_init_readonly): Likewise.
	(_IO_str_overflow): Likewise.
	(_IO_str_underflow): Likewise.
	(_IO_str_count): Likewise.
	(_IO_str_seekoff): Likewise.
	(_IO_str_pbackfail): Likewise.
	(_IO_str_finish): Likewise.
	* libio/wstrops.c (_IO_wstr_init_static): Likewise.
	(_IO_wstr_overflow): Likewise.
	(_IO_wstr_underflow): Likewise.
	(_IO_wstr_count): Likewise.
	(_IO_wstr_seekoff): Likewise.
	(_IO_wstr_pbackfail): Likewise.
	(_IO_wstr_finish): Likewise.
	* locale/programs/localedef.c (normalize_codeset): Likewise.
	* locale/programs/locarchive.c (add_locale_to_archive): Likewise.
	(add_locales_to_archive): Likewise.
	(delete_locales_from_archive): Likewise.
	* malloc/malloc.c (__libc_mallinfo): Likewise.
	* math/gen-auto-libm-tests.c (init_fp_formats): Likewise.
	* misc/tsearch.c (__tfind): Likewise.
	* nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Likewise.
	* nptl/pthread_attr_getdetachstate.c
	(__pthread_attr_getdetachstate): Likewise.
	* nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
	Likewise.
	* nptl/pthread_attr_getinheritsched.c
	(__pthread_attr_getinheritsched): Likewise.
	* nptl/pthread_attr_getschedparam.c
	(__pthread_attr_getschedparam): Likewise.
	* nptl/pthread_attr_getschedpolicy.c
	(__pthread_attr_getschedpolicy): Likewise.
	* nptl/pthread_attr_getscope.c (__pthread_attr_getscope):
	Likewise.
	* nptl/pthread_attr_getstack.c (__pthread_attr_getstack):
	Likewise.
	* nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
	Likewise.
	* nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
	Likewise.
	* nptl/pthread_attr_init.c (__pthread_attr_init_2_1): Likewise.
	(__pthread_attr_init_2_0): Likewise.
	* nptl/pthread_attr_setdetachstate.c
	(__pthread_attr_setdetachstate): Likewise.
	* nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
	Likewise.
	* nptl/pthread_attr_setinheritsched.c
	(__pthread_attr_setinheritsched): Likewise.
	* nptl/pthread_attr_setschedparam.c
	(__pthread_attr_setschedparam): Likewise.
	* nptl/pthread_attr_setschedpolicy.c
	(__pthread_attr_setschedpolicy): Likewise.
	* nptl/pthread_attr_setscope.c (__pthread_attr_setscope):
	Likewise.
	* nptl/pthread_attr_setstack.c (__pthread_attr_setstack):
	Likewise.
	* nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
	Likewise.
	* nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
	Likewise.
	* nptl/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* nptl/pthread_create.c (__find_in_stack_list): Likewise.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
	* nptl/pthread_mutex_cond_lock.c (__pthread_mutex_lock): Define to
	use internal_function.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Convert to
	prototype-style function definition.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	(__pthread_mutex_cond_lock_adjust): Likewise.  Use
	internal_function.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock):
	Convert to prototype-style function definition.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock):
	Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Likewise.
	(__pthread_mutex_unlock): Likewise.
	* nptl_db/td_ta_clear_event.c (td_ta_clear_event): Likewise.
	* nptl_db/td_ta_set_event.c (td_ta_set_event): Likewise.
	* nptl_db/td_thr_clear_event.c (td_thr_clear_event): Likewise.
	* nptl_db/td_thr_event_enable.c (td_thr_event_enable): Likewise.
	* nptl_db/td_thr_set_event.c (td_thr_set_event): Likewise.
	* nss/makedb.c (process_input): Likewise.
	* posix/fnmatch.c (__strchrnul): Likewise.
	(__wcschrnul): Likewise.
	(fnmatch): Likewise.
	* posix/fnmatch_loop.c (FCT): Likewise.
	* posix/glob.c (globfree): Likewise.
	(__glob_pattern_type): Likewise.
	(__glob_pattern_p): Likewise.
	* posix/regcomp.c (re_compile_pattern): Likewise.
	(re_set_syntax): Likewise.
	(re_compile_fastmap): Likewise.
	(regcomp): Likewise.
	(regerror): Likewise.
	(regfree): Likewise.
	* posix/regexec.c (regexec): Likewise.
	(re_match): Likewise.
	(re_search): Likewise.
	(re_match_2): Likewise.
	(re_search_2): Likewise.
	(re_search_stub): Likewise.  Use internal_function
	(re_copy_regs): Likewise.
	(re_set_registers): Convert to prototype-style function
	definition.
	(prune_impossible_nodes): Likewise.  Use internal_function.
	* resolv/inet_net_pton.c (inet_net_pton): Convert to
	prototype-style function definition.
	(inet_net_pton_ipv4): Likewise.
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Likewise.
	* sysdeps/pthread/aio_cancel.c (aio_cancel): Likewise.
	* sysdeps/pthread/aio_suspend.c (aio_suspend): Likewise.
	* sysdeps/pthread/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	Make variadic.
	* time/strptime_l.c (localtime_r): Convert to prototype-style
	function definition.
	* wcsmbs/mbsnrtowcs.c (__mbsnrtowcs): Likewise.
	* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Likewise.
	* wcsmbs/wcsnrtombs.c (__wcsnrtombs): Likewise.
	* wcsmbs/wcsrtombs.c (__wcsrtombs): Likewise.
2015-10-20 11:54:09 +00:00
Joseph Myers 2f44ee08db Fix regcomp wcscoll, wcscmp namespace (bug 18497).
regcomp brings in references to wcscoll, which isn't in all the
standards that contain regcomp.  In turn, wcscoll brings in references
to wcscmp, also not in all those standards.  This patch fixes this by
making those functions into weak aliases of __wcscoll and __wcscmp and
calling those names instead as needed.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed shared libraries is unchanged by the patch).

	[BZ #18497]
	* wcsmbs/wcscmp.c [!WCSCMP] (WCSCMP): Define as __wcscmp instead
	of wcscmp.
	(wcscmp): Define as weak alias of WCSCMP.
	* wcsmbs/wcscoll.c (STRCOLL): Define as __wcscoll instead of
	wcscoll.
	(USE_HIDDEN_DEF): Define.
	[!USE_IN_EXTENDED_LOCALE_MODEL] (wcscoll): Define as weak alias of
	__wcscoll.  Don't use libc_hidden_weak.
	* wcsmbs/wcscoll_l.c (STRCMP): Define as __wcscmp instead of
	wcscmp.
	* sysdeps/i386/i686/multiarch/wcscmp-c.c
	[SHARED] (libc_hidden_def): Define __GI___wcscmp instead of
	__GI_wcscmp.
	(weak_alias): Undefine and redefine.
	* sysdeps/i386/i686/multiarch/wcscmp.S (wcscmp): Rename to
	__wcscmp and define as weak alias of __wcscmp.
	* sysdeps/x86_64/wcscmp.S (wcscmp): Likewise.
	* include/wchar.h (__wcscmp): Declare.  Use libc_hidden_proto.
	(__wcscoll): Likewise.
	(wcscmp): Don't use libc_hidden_proto.
	(wcscoll): Likewise.
	* posix/regcomp.c (build_range_exp): Call __wcscoll instead of
	wcscoll.
	* posix/regexec.c (check_node_accept_bytes): Likewise.
	* conform/Makefile (test-xfail-XPG3/regex.h/linknamespace): Remove
	variable.
	(test-xfail-XPG4/regex.h/linknamespace): Likewise.
	(test-xfail-POSIX/regex.h/linknamespace): Likewise.
2015-06-09 21:07:30 +00:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Roland McGrath 8c0ab919f6 Move findidx nested functions to top-level. 2014-09-11 16:02:17 -07:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Ryan S. Arnold e054f49430 Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
Andreas Schwab a445af0bc7 Fix buffer overrun in regexp matcher 2013-02-12 09:30:34 +01:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Andreas Schwab f3a6cc0a56 Fix access after end of search string in regex matcher 2011-11-30 11:03:20 +01:00
Ulrich Drepper 8887a920a4 Fix unnecessary overallocation due to incomplete character
When incomplete characters are found at the end of a string the
code ran amok and allocated lots of memory.  Stricter limits
are now in place.
2011-05-28 17:14:30 -04:00
Jim Meyering 2543fef229 Fix infloop on persistent failing calloc in regex. 2010-12-27 18:19:56 -05:00
Andreas Schwab d84acf388e Fix lookup of collation sequence value during regexp matching 2010-05-05 09:59:25 -07:00
Paul Eggert aef699dce1 regexec.c: avoid overflow in realloc buffer length computation 2010-01-22 12:41:12 -08:00
Paul Eggert 74bc9f14db regexec.c: avoid leaks on out-of-memory failure paths 2010-01-22 12:33:58 -08:00
Paul Eggert 42a2c9b5c3 regexec.c: avoid overflow in computing sum of lengths 2010-01-22 12:22:18 -08:00
Paul Eggert eadc09f22c re_search_internal: Avoid overflow in computing re_malloc buffer size 2010-01-22 12:15:53 -08:00
Paul Eggert 4cd028677b prune_impossible_nodes: Avoid overflow in computing re_malloc buffer size 2010-01-22 12:03:56 -08:00
Paul Eggert daa8454919 regexec.c: avoid arithmetic overflow in buffer size calculation 2010-01-22 10:52:38 -08:00
Paul Eggert d044d844dd regexec.c: simplify re_search_2_stub 2010-01-22 10:39:59 -08:00
Ulrich Drepper 2da42bc065 Fix a few more cases of ignored return values in regex. 2010-01-15 12:03:16 -08:00
Ulrich Drepper 76c7f2cd8a [BZ 697]
* posix/regexec.c (prune_impossible_nodes): Handle sifted_states[0]
	being NULL also if there are no backreferences.
	* posix/rxspencer/tests: Add testcases.
2009-01-08 00:47:30 +00:00
Ulrich Drepper b7d1c5fa30 * posix/fnmatch_loop.c: Take rule index returned as part of
findidx return value into account when accessing weights.
	* posix/regcomp.c: Likewise.
	* posix/regexec.c: Likewise.
2007-10-12 17:47:19 +00:00
Ulrich Drepper 1ba81cea27 * posix/regexec.c: Finish prototyping of static functions.
* posix/regex_internal.c: Likewise.
2005-10-15 15:23:33 +00:00
Ulrich Drepper 513bbb254d [BZ #1373]
2005-10-13  Ulrich Drepper  <drepper@redhat.com>
	[BZ #1373]
	* argp/argp.h: Remove __NTH for __argp_usage inline function.
2005-10-14 05:54:47 +00:00
Ulrich Drepper e2f5526407 [BZ #1231]
2005-08-23  Paul Eggert  <eggert@cs.ucla.edu>
	[BZ #1231]
	* posix/regex_internal.c (re_string_skip_chars, register_state,
	calc_state_hash): Remove forward decls.
	* posix/regexec.c (acquire_init_state_context, check_halt_node_context,
	proceed_next_node, pop_fail_stack, sub_epsilon_src_nodes,
	clean_state_log_if_needed): Likewise.

	* posix/regex.c: No need to use K&R definitions for static functions.
	* posix/regex_internal.c: Likewise.
2005-10-13 20:08:58 +00:00
Ulrich Drepper c0c9615cbb * posix/regexec.c (update_cur_sifted_state, check_arrival,
check_arrival_add_next_nodes): Avoid using uninitialized variable.

	* malloc/memusage.c (dest): Fix a bunch of warnings on 32-bit arches.

	* sysdeps/i386/fpu/libm-test-ulps: Update for GCC 4.0.x.
2005-09-30 15:46:19 +00:00
Ulrich Drepper 2c05d33f90 [BZ #1302]
2005-09-06  Paul Eggert  <eggert@cs.ucla.edu>
            Ulrich Drepper  <drepper@redhat.com>

	[BZ #1302]
	Change bitset word type from unsigned int to unsigned long int,
	as this has better performance on typical 64-bit hosts.  Change
	bitset type name to bitset_t.
	* posix/regcomp.c (build_equiv_class, build_charclass):
	(build_range_exp, build_collating_symbol):
	Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
	argument is a bitset.  This is merely a style issue, but it makes
	it clearer that an entire array is expected.
	(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
	lower_subexp): Adjust for new bitset_t definition.
	(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
	* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
	bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
	* posix/regexec.c (check_dst_limits_calc_pos_1,
	check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
	Likewise.
	* posix/regcomp.c (utf8_sb_map): Don't assume initializer
	== 0xffffffff.
	* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
	All uses changed.
	(BITSET_WORDS): Renamed from BITSET_UINTS.  All uses changed.
	(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
	All uses changed.
	(BITSET_WORD_MAX): New macro.
	(bitset_set, bitset_clear, bitset_contain, bitset_empty,
	(bitset_set_all, bitset_copy):  Adjust for bitset_t change.
	(bitset_empty, bitset_copy):
	Prefer sizeof (bitset_t) to multiplying it out ourselves.
	(bitset_not_merge): Remove; unused.
	(bitset_contain): Return bool, not unsigned int with one bit on.
	All callers changed.
	* posix/regexec.c (build_trtable): Don't assume bitset_t has no
	stricter alignment than re_node_set; do this by defining a new
	internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
Ulrich Drepper 997470b3e1 [BZ #281]
* posix/regex.h: Define RE_TRANSLATE_TYPE as unsigned char *.
	* posix/regcomp.c: Remove unnecessary uses of
	unsigned RE_TRANSLATE_TYPE.
	* posix/regex_internal.h: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regexexec.c: Likewise.
	Based on a patch by Stepan Kasal <kasal@ucw.cz>.
2005-09-23 06:11:29 +00:00
Ulrich Drepper 76b864c8e0 (update_cur_sifted_state): Likewise.
(re_search_internal): Likewise.
	(prune_impossible_nodes): Likewise.
	(acquire_init_state_context): Likewise.
	(proceed_next_node): Likewise.
	(set_regs): Likewise.
	(free_fail_stack_return): Likewise.
	(check_subexp_limits): Likewise.
	(sub_epsilon_src_nodes):  Likewise.
	(add_epsilon_src_nodes):  Likewise.
	(merge_state_array): Likewise.
	(update_regs): Likewise.
	(build_trtable): Likewise.
	(sift_states_backward): Mark MCTX parameter as const.
	(build_sifted_states): Likewise.
	(update_cur_sifted_state): Likewise.
	(sift_states_mkref): Likewise.
	(check_dst_limits_calc_pos_1): Likewise.
	* posix/regex_internal.h (re_match_context_t): Make dfa a const
	pointer.
2005-09-07 16:15:23 +00:00
Ulrich Drepper 6efbd82c5c (transit_state_bkref): Make DFA a const pointer.
(get_subexp): Likewise.
	(check_arrival): Likewise.
	(check_arrival_expand_ecl): Mark DFA parameter as const.
	(check_arrival_expand_ecl_sub): Likewise.
	(check_arrival_expand_ecl): Mark eclosure as const.
2005-09-07 15:26:18 +00:00
Ulrich Drepper 1878e9af92 * posix/regexec.c (find_recover_state): Remove unnecessary
initialization.
2005-09-07 07:16:24 +00:00
Ulrich Drepper c42b4152ab * posix/regexec.c (merge_state_with_log): Define dfa as const pointer.
(transit_state_sb): Likewise.
	(transit_state_mb): Likewise.
	(sift_states_iter_mb): Likewise.
	(check_arrival_add_next_nodes): Likewise.
	(check_node_accept_bytes): Change first parameter to pointer-to-const.
	[_LIBC] (re_search_2_stub): Use mempcpy.
2005-09-07 05:41:42 +00:00
Ulrich Drepper 01ed6ceb7c * posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.

2005-09-01  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
	bugs in int versus size_t comparisons.

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
	a pointer-to-const.
	(re_acquire_state_context): Likewise.
	* posix/regex_internal.h: Adjust prototypes.

2005-08-31  Jim Meyering  <jim@meyering.net>

	* posix/regcomp.c (search_duplicated_node): Make first pointer arg
	a pointer-to-const.
	* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
	register_state): Likewise.
	* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
	(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
	(group_nodes_into_DFAstates): Likewise.

	* posix/regexec.c (re_search_internal): Simplify update of
	rm_so and rm_eo by replacing "if (A == B) A += C - B;"
	with the equivalent of "if (A == B) A = C;".

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* posix/regcomp.c (re_compile_internal): Change third parameter type
	to size_t.
	(init_dfa): Likewise.  Make sure that arithmetic on pat_len doesn't
	overflow.
	* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
	and nodes_len to size_t.
	* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
	new_nodes_alloc.  Check for overflow.

2005-08-31  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
	(optimize_subexps, lower_subexp):
	Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
	since the signed shift might overflow.  Use 1u<<31 instead.
	* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
	Likewise.
	* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
	(check_subexp_matching_top): Likewise.
	* posix/regcomp.c (optimize_subexps, lower_subexp):
	Use CHAR_BIT rather than 8, for clarity.
	* posix/regexec.c (check_dst_limits_calc_pos_1):
	(check_subexp_matching_top): Likewise.
	* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
	don't have to worry about portability issues when shifting it left.
	Remove no-longer-needed test for table_size > 0.
	* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
	are in a word, as the resulting behavior is undefined.
	* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
	in one case, a <= should have been an <, and in another case the
	whole test was missing.
	* posix/regex_internal.h (BYTE_BITS): Remove.  All uses changed to
	the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
Ulrich Drepper 2d87db5b53 * posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
	(struct re_dfa_t): Remove unused member states_alloc.
	* posix/regcomp.c (init_dfa): Don't initialize unused members.

2005-08-25  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regexec.c (set_regs): Don't alloca with an unbounded size.

	alloca modernization/simplification for regex.
	* posix/regex.c: Remove portability cruft for alloca.  This no longer
	needs to be at the start of the file, and can be moved into
	regex_internal.h and simplified.
	* posix/regex_internal.h: Include <alloca.h>.
	(__libc_use_alloca) [!defined _LIBC]: New macro.
	* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
	since the code now works outside glibc.

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* include/regex.h: Remove use of _RE_ARGS.

2005-08-25  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regexec.c (find_recover_state): Change "err" to "*err".

2005-08-24  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regcomp.c (regerror): Pointer args are 'restrict',
	as per POSIX.
	* posix/regex.h (regerror): Likewise.
	* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
	Similarly for regcomp and regexec.  Also, first 2 args of regexec
	and 2nd arg of regerror are const.

	* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
	requires this.  (The code never needed it.)

2005-08-20  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
	int, not reg_errcode_t.

	* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
	since some broken compilers warn about it otherwise.

	* posix/regcomp.c (create_initial_state): Remove duplicate decl.

2005-08-20  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regex.h (_RE_ARGS): Remove.  No longer needed, since we assume
	C89 or better.  All uses removed.

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* posix/regex.c: Prevent using C++ compilers.

2005-08-19  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regcomp.c (duplicate_node): Return new index, not an error
	code, and let the caller return REG_ESPACE if out of space.  This
	removes an uninitialied-variable warning with GCC 4.0.1, and also
	avoids taking the address of a local variable.  All callers
	changed.

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* include/time.h (__strptime_internal): Rename parameter to avoid
	bogus compiler warning.

2005-08-19  Jim Meyering  <jim@meyering.net>

	* posix/regexec.c (proceed_next_node): Redo local variables to
	avoid GCC shadowing warnings.

2005-09-06  Ulrich Drepper  <drepper@redhat.com>

	* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
	(re_acquire_state_context): Likewise.

2005-08-19  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regex_internal.c (re_string_realloc_buffers):
	(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
	Rename local variables to avoid GCC shadowing warnings.

2005-07-08  Eric Blake  <ebb9@byu.net>
            Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
	wchar_t.  Remove now-unnecessary cast.
	(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
Ulrich Drepper 7b91899345 [BZ #934]
2005-05-06  Jakub Jelinek  <jakub@redhat.com>
	[BZ #934]
	* posix/regex_internal.h: Include bits/libc-lock.h or define dummy
	__libc_lock_* macros if not _LIBC.
	(struct re_dfa_t): Add lock.
	* posix/regcomp.c (re_compile_internal): Add __libc_lock_init.
	* posix/regexec.c (regexec, re_search_stub): Add locking.
2005-05-06 23:34:44 +00:00