public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
* [2.29 COMMITTED] regex: fix read overrun [BZ #24114]
@ 2019-01-01  0:00 Aurelien Jarno
  2019-01-01  0:00 ` Rafal Luzynski
  2019-01-01  0:00 ` [2.29 COMMITTED] Record CVE-2019-9169 in NEWS and ChangeLog " Aurelien Jarno
  0 siblings, 2 replies; 9+ messages in thread
From: Aurelien Jarno @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libc-stable; +Cc: Paul Eggert

From: Paul Eggert <eggert@cs.ucla.edu>

Problem found by AddressSanitizer, reported by Hongxu Chen in:
https://debbugs.gnu.org/34140
* posix/regexec.c (proceed_next_node):
Do not read past end of input buffer.

(cherry picked from commit 583dd860d5b833037175247230a328f0050dbfe9)
---
 ChangeLog       | 8 ++++++++
 posix/regexec.c | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 90558e434ce..fb88626efe1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-01-31  Paul Eggert  <eggert@cs.ucla.edu>
+
+	regex: fix read overrun [BZ #24114]
+	Problem found by AddressSanitizer, reported by Hongxu Chen in:
+	https://debbugs.gnu.org/34140
+	* posix/regexec.c (proceed_next_node):
+	Do not read past end of input buffer.
+
 2019-03-13  Stefan Liebler  <stli@linux.ibm.com>
 
 	* elf/dl-sysdep.c (_dl_show_auxv): Remove condition and always
diff --git a/posix/regexec.c b/posix/regexec.c
index 91d5a797b82..084b1222d95 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
 	      else if (naccepted)
 		{
 		  char *buf = (char *) re_string_get_buffer (&mctx->input);
-		  if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
-			      naccepted) != 0)
+		  if (mctx->input.valid_len - *pidx < naccepted
+		      || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+				  naccepted)
+			  != 0))
 		    return -1;
 		}
 	    }
-- 
2.20.1

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

end of thread, other threads:[~2019-03-19 22:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [2.29 COMMITTED] regex: fix read overrun [BZ #24114] Aurelien Jarno
2019-01-01  0:00 ` Rafal Luzynski
2019-01-01  0:00   ` Paul Eggert
2019-01-01  0:00   ` Aurelien Jarno
2019-01-01  0:00     ` Rafal Luzynski
2019-01-01  0:00   ` Florian Weimer
2019-01-01  0:00     ` Rafal Luzynski
2019-01-01  0:00       ` Florian Weimer
2019-01-01  0:00 ` [2.29 COMMITTED] Record CVE-2019-9169 in NEWS and ChangeLog " Aurelien Jarno

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