From: Aurelien Jarno <aurelien@aurel32.net>
To: libc-stable@sourceware.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [2.29 COMMITTED] regex: fix read overrun [BZ #24114]
Date: Tue, 01 Jan 2019 00:00:00 -0000 [thread overview]
Message-ID: <20190316223151.29219-1-aurelien@aurel32.net> (raw)
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
next reply other threads:[~2019-03-16 22:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-01 0:00 Aurelien Jarno [this message]
2019-01-01 0:00 ` [2.29 COMMITTED] Record CVE-2019-9169 in NEWS and ChangeLog " Aurelien Jarno
2019-01-01 0:00 ` [2.29 COMMITTED] regex: fix read overrun " Rafal Luzynski
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 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190316223151.29219-1-aurelien@aurel32.net \
--to=aurelien@aurel32.net \
--cc=eggert@cs.ucla.edu \
--cc=libc-stable@sourceware.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).