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