blob: cf3744b24aabbc44980c7461ec2cce3b043e2106 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001CVE: CVE-2019-9169
Brad Bishop96ff1982019-08-19 13:50:42 -04002CVE: CVE-2018-20796
Brad Bishop19323692019-04-05 15:28:33 -04003Upstream-Status: Backport
4Signed-off-by: Ross Burton <ross.burton@intel.com>
5
6From 583dd860d5b833037175247230a328f0050dbfe9 Mon Sep 17 00:00:00 2001
7From: Paul Eggert <eggert@cs.ucla.edu>
8Date: Mon, 21 Jan 2019 11:08:13 -0800
9Subject: [PATCH] regex: fix read overrun [BZ #24114]
10
11Problem found by AddressSanitizer, reported by Hongxu Chen in:
12https://debbugs.gnu.org/34140
13* posix/regexec.c (proceed_next_node):
14Do not read past end of input buffer.
15---
16 posix/regexec.c | 6 ++++--
17 2 files changed, 13 insertions(+), 3 deletions(-)
18
19diff --git a/posix/regexec.c b/posix/regexec.c
20index 91d5a79..084b122 100644
21--- a/posix/regexec.c
22+++ b/posix/regexec.c
23@@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
24 else if (naccepted)
25 {
26 char *buf = (char *) re_string_get_buffer (&mctx->input);
27- if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
28- naccepted) != 0)
29+ if (mctx->input.valid_len - *pidx < naccepted
30+ || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
31+ naccepted)
32+ != 0))
33 return -1;
34 }
35 }
36--
372.9.3