unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] regex: fix buffer read overrun in search [BZ#28470]
@ 2021-10-18 22:15 Paul Eggert
  2021-10-19  7:17 ` Andreas Schwab
  0 siblings, 1 reply; 13+ messages in thread
From: Paul Eggert @ 2021-10-18 22:15 UTC (permalink / raw)
  To: libc-alpha

Problem reported by Benno Schulenberg in:
https://lists.gnu.org/r/bug-gnulib/2021-10/msg00035.html
* posix/regexec.c (re_search_internal): Use better bounds check.
---
 posix/regexec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/posix/regexec.c b/posix/regexec.c
index 83e9aaf8ca..a955aa2182 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -760,7 +760,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
 		}
 	      /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
 		 Note that MATCH_FIRST must not be smaller than 0.  */
-	      ch = (match_first >= length
+	      ch = (mctx.input.valid_len <= offset
 		    ? 0 : re_string_byte_at (&mctx.input, offset));
 	      if (fastmap[ch])
 		break;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-26 18:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 22:15 [PATCH] regex: fix buffer read overrun in search [BZ#28470] Paul Eggert
2021-10-19  7:17 ` Andreas Schwab
2021-10-19  8:13   ` Paul Eggert
2021-10-19  8:25     ` Andreas Schwab
2021-10-19  8:57       ` Paul Eggert
2021-10-19 15:09         ` Andreas Schwab
2021-10-19 18:14           ` Paul Eggert
2021-11-24 22:27             ` Paul Eggert
2021-11-24 22:45               ` Andreas Schwab
2021-11-24 23:50                 ` Paul Eggert
2021-11-25  9:01                   ` Andreas Schwab
2021-11-26 18:35                     ` Paul Eggert
2021-11-26 18:39                       ` Andreas Schwab

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).