From: Andreas Schwab <schwab@linux-m68k.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] regex: fix buffer read overrun in search [BZ#28470]
Date: Tue, 19 Oct 2021 17:09:15 +0200 [thread overview]
Message-ID: <87k0i9oxus.fsf@igel.home> (raw)
In-Reply-To: <b662b6a9-d798-5ddd-1048-a161ab0778b0@cs.ucla.edu> (Paul Eggert's message of "Tue, 19 Oct 2021 01:57:26 -0700")
On Okt 19 2021, Paul Eggert wrote:
> diff --git a/posix/regexec.c b/posix/regexec.c
> index 83e9aaf8ca..6aeba3c0b4 100644
> --- a/posix/regexec.c
> +++ b/posix/regexec.c
> @@ -758,10 +758,9 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
>
> offset = match_first - mctx.input.raw_mbs_idx;
> }
> - /* 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
> - ? 0 : re_string_byte_at (&mctx.input, offset));
> + /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */
> + ch = (offset < mctx.input.valid_len
> + ? re_string_byte_at (&mctx.input, offset) : 0);
Why is the bug not in re_string_reconstruct? Since string[match_first]
exists, so should re_string_byte_at (&mctx.input, offset).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
next prev parent reply other threads:[~2021-10-19 15:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0i9oxus.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=eggert@cs.ucla.edu \
--cc=libc-alpha@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).