summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-05-01 09:10:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2023-05-01 11:21:18 -0700
commitbdc715b1f7a4eee75214709d4a949bdf65bcc9a2 (patch)
treebbb4ecce636c2206ec8f923cee9700f82e91ec32
parenta1d7a312646ec112140f4a3e112daac2194549df (diff)
downloadgnulib-bdc715b1f7a4eee75214709d4a949bdf65bcc9a2.tar.gz
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.
-rw-r--r--ChangeLog6
-rw-r--r--lib/regex_internal.h1
-rw-r--r--lib/regexec.c2
-rw-r--r--modules/regex1
4 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3528faf40e..55f010adac 100644
--- 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.
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index ae9257eac0..0270091df7 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -29,6 +29,7 @@
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
+#include <stdckdint.h>
#include <stdint.h>
#ifndef _LIBC
diff --git a/lib/regexec.c b/lib/regexec.c
index 13e0349e72..f05f38ae0e 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -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. */
diff --git a/modules/regex b/modules/regex
index dfe0c2918e..e38479858f 100644
--- a/modules/regex
+++ b/modules/regex
@@ -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]