]> Savannah Git Hosting - gnulib.git/commitdiff
regex: prefer C23 style overflow checking
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 May 2023 16:10:17 +0000 (09:10 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 May 2023 18:21:18 +0000 (11:21 -0700)
* lib/regex_internal.h: Include stdckdint.h.
* lib/regexec.c (re_search_2_stub):
* modules/regex (Depends-on): Add stdckdint.
Prefer stdckdint.h to intprops.h macros.

ChangeLog
lib/regex_internal.h
lib/regexec.c
modules/regex

index 3528faf40ea45986488a602e0bb118c532c07207..55f010adacc909751be48c5f064bba30e490db4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2023-05-01  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex: prefer C23 style overflow checking
+       * lib/regex_internal.h: Include stdckdint.h.
+       * lib/regexec.c (re_search_2_stub):
+       * modules/regex (Depends-on): Add stdckdint.
+       Prefer stdckdint.h to intprops.h macros.
+
        dynarray: prefer C23 style overflow checking
        * lib/malloc/dynarray_emplace_enlarge.c, lib/malloc/dynarray_resize.c:
        Include stdckdint.h, not intprops.h.
index ae9257eac002323727d1a1c3cce10b8acc8eab0d..0270091df7016fa9ddb80e8f94d37c14e031674a 100644 (file)
@@ -29,6 +29,7 @@
 #include <locale.h>
 #include <wchar.h>
 #include <wctype.h>
+#include <stdckdint.h>
 #include <stdint.h>
 
 #ifndef _LIBC
index 13e0349e7276dbd2bd2d2f97f1f500de0df37776..f05f38ae0e00a3870a5cd5068253225f5a61ffc1 100644 (file)
@@ -324,7 +324,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
   char *s = NULL;
 
   if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
-                        || INT_ADD_WRAPV (length1, length2, &len))))
+                        || ckd_add (&len, length1, length2))))
     return -2;
 
   /* Concatenate the strings.  */
index dfe0c2918e2afc10f49d8936570deb96eb4d97a5..e38479858f80b9f9e9aa358bec16363cf91bdfd2 100644 (file)
@@ -35,6 +35,7 @@ mbrtowc                 [test $ac_use_included_regex = yes]
 mbsinit                 [test $ac_use_included_regex = yes]
 nl_langinfo             [test $ac_use_included_regex = yes]
 stdbool                 [test $ac_use_included_regex = yes]
+stdckdint               [test $ac_use_included_regex = yes]
 stdint                  [test $ac_use_included_regex = yes]
 verify                  [test $ac_use_included_regex = yes]
 wchar                   [test $ac_use_included_regex = yes]