bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 3/4] regex: tell compiler there’s at most 256 arcs out
Date: Wed,  9 Oct 2019 18:34:26 -0700	[thread overview]
Message-ID: <20191010013427.16129-3-eggert@cs.ucla.edu> (raw)
In-Reply-To: <20191010013427.16129-1-eggert@cs.ucla.edu>

Partly this is to help the reader (and maybe help GCC);
partly this is to pacify Coverity.
* lib/regex_internal.h: Include verify.h.
* lib/regexec.c (group_nodes_into_DFAstates):
Tell the compiler that ndests cannot exceed SBC_MAX.
* modules/regex (Depends-on): Add ‘verify’.
---
 ChangeLog            | 8 ++++++++
 lib/regex_internal.h | 1 +
 lib/regexec.c        | 1 +
 modules/regex        | 1 +
 4 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4f96c8cbf..360973ba4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2019-10-09  Paul Eggert  <eggert@cs.ucla.edu>
 
+	regex: tell compiler there’s at most 256 arcs out
+	Partly this is to help the reader (and maybe help GCC);
+	partly this is to pacify Coverity.
+	* lib/regex_internal.h: Include verify.h.
+	* lib/regexec.c (group_nodes_into_DFAstates):
+	Tell the compiler that ndests cannot exceed SBC_MAX.
+	* modules/regex (Depends-on): Add ‘verify’.
+
 	regex: simplify by assuming C99
 	* config/srclist.txt: Comment out regex_internal.h and regexec.c
 	temporarily.
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 9c0e1f1d1..b6eeba32d 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -34,6 +34,7 @@
 #include <stdint.h>
 
 #include <intprops.h>
+#include <verify.h>
 
 #ifdef _LIBC
 # include <libc-lock.h>
diff --git a/lib/regexec.c b/lib/regexec.c
index f7d2b5b20..0d32e0139 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -3684,6 +3684,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
 	  bitset_empty (accepts);
 	}
     }
+  assume (ndests <= SBC_MAX);
   return ndests;
  error_return:
   for (j = 0; j < ndests; ++j)
diff --git a/modules/regex b/modules/regex
index 7f50916ce..dbfd37982 100644
--- a/modules/regex
+++ b/modules/regex
@@ -30,6 +30,7 @@ mbsinit         [test $ac_use_included_regex = yes]
 nl_langinfo     [test $ac_use_included_regex = yes]
 stdbool         [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]
 wcrtomb         [test $ac_use_included_regex = yes]
 wctype-h        [test $ac_use_included_regex = yes]
-- 
2.21.0



  parent reply	other threads:[~2019-10-10  1:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  1:34 [PATCH 1/4] regex: avoid copying of uninitialized storage Paul Eggert
2019-10-10  1:34 ` [PATCH 2/4] regex: simplify by assuming C99 Paul Eggert
2019-10-12 10:41   ` Bruno Haible
2019-10-10  1:34 ` Paul Eggert [this message]
2019-10-10  1:34 ` [PATCH 4/4] regex: omit debug assignment when not debugging Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191010013427.16129-3-eggert@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).