From patchwork Sun Dec 16 15:11:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 30685 Received: (qmail 27498 invoked by alias); 16 Dec 2018 15:11: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 27368 invoked by uid 89); 16 Dec 2018 15:11:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1013, exhausted, H*Ad:D*edu X-HELO: zimbra.cs.ucla.edu From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [INSTALLED 2/2] regex: fix storage-exhaustion error Date: Sun, 16 Dec 2018 07:11:05 -0800 Message-Id: <20181216151105.31863-2-eggert@cs.ucla.edu> In-Reply-To: <20181216151105.31863-1-eggert@cs.ucla.edu> References: <20181216151105.31863-1-eggert@cs.ucla.edu> MIME-Version: 1.0 [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 2fef13ec02..e0e7a74011 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-12-15 Paul Eggert + + regex: fix storage-exhaustion error + [BZ #18040] + * posix/regexec.c (get_subexp): + Do not continue if storage is exhausted. + 2018-12-15 Assaf Gordon regex: fix heap-use-after-free error diff --git a/posix/regexec.c b/posix/regexec.c index a29e8ad1ff..ecb430d302 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -2786,6 +2786,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 (__glibc_unlikely (err != REG_NOERROR)) + return err; } } return REG_NOERROR;