From patchwork Sun Sep 9 15:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 29277 Received: (qmail 98253 invoked by alias); 9 Sep 2018 15:12:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 98147 invoked by uid 89); 9 Sep 2018 15:12:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:D*ucla.edu, exhausted, H*Ad:D*edu X-HELO: zimbra.cs.ucla.edu X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Quarantine-ID: X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 2/2] regex: fix storage-exhaustion error Date: Sun, 9 Sep 2018 08:12:07 -0700 Message-Id: <20180909151207.2903-2-eggert@cs.ucla.edu> In-Reply-To: <20180909151207.2903-1-eggert@cs.ucla.edu> References: <20180909151207.2903-1-eggert@cs.ucla.edu> In-Reply-To: <48cb516b-dc86-f174-9abb-4df06f05f845@cs.ucla.edu> References: <48cb516b-dc86-f174-9abb-4df06f05f845@cs.ucla.edu> [BZ #23610][BZ #18040] * posix/regexec.c (get_subexp): Do not continue if storage is exhausted. --- ChangeLog | 7 +++++++ posix/regexec.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index cf69a33d73..0d865c4eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-09-09 Paul Eggert + + regex: fix storage-exhaustion error + [BZ #23609][BZ #18040] + * posix/regexec.c (get_subexp): + Do not continue if storage is exhausted. + 2018-09-09 Assaf Gordon regex: fix heap-use-after-free error diff --git a/posix/regexec.c b/posix/regexec.c index 61a4ea26d1..0bef862dca 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -2780,6 +2780,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) buf = (const char *) re_string_get_buffer (&mctx->input); if (err == REG_NOMATCH) continue; + if (BE (err != REG_NOERROR, 0)) + return err; } } return REG_NOERROR;