2016-12-16 Paul Eggert <eggert@cs.ucla.edu>
+ regex: fix integer-overflow bug in never-used code
+ Problem reported by Clément Pit–Claudel in:
+ http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00654.html
+ * lib/regex_internal.h: Include intprops.h.
+ * lib/regexec.c (re_search_2_stub): Use it to avoid undefined
+ behavior on integer overflow.
+ * modules/regex (Depends-on): Add intprops.
+
fpending: fix port to MinGW on Emacs
* lib/stdio-impl.h [__MINGW32__]: Do not include errno.h.
Problem reported by Eli Zaretskii in:
#include <stdbool.h>
#include <stdint.h>
+#include "intprops.h"
+
#ifdef _LIBC
# include <libc-lock.h>
# define lock_define(name) __libc_lock_define (, name)
{
const char *str;
regoff_t rval;
- Idx len = length1 + length2;
+ Idx len;
char *s = NULL;
- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
+ if (BE ((length1 < 0 || length2 < 0 || stop < 0
+ || INT_ADD_WRAPV (length1, length2, &len)),
+ 0))
return -2;
/* Concatenate the strings. */
alloca-opt [test $ac_use_included_regex = yes]
btowc [test $ac_use_included_regex = yes]
gettext-h [test $ac_use_included_regex = yes]
+intprops [test $ac_use_included_regex = yes]
lock [test "$ac_cv_gnu_library_2_1:$ac_use_included_regex" = no:yes]
memcmp [test $ac_use_included_regex = yes]
memmove [test $ac_use_included_regex = yes]