Commit 788d69c0 authored by Thaodan's avatar Thaodan

[glibc] Add fix for GLIBC#11053. Contributes to JB#44353

This patches that fixes GLIBC#11053 then in turn fixes GNU-GREP#29613.
parent e7b403c8
From fc141ea78ee3d87c67b18488827fe2d89c9343e7 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 30 Oct 2019 10:38:36 +0100
Subject: [PATCH] Fix array bounds violation in regex matcher (bug 25149)
If the regex has more subexpressions than the number of elements allocated
in the regmatch_t array passed to regexec then proceed_next_node may
access the regmatch_t array outside its bounds.
No testcase added because even without this bug it would then crash in
pop_fail_stack which is bug 11053.
---
posix/regexec.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/posix/regexec.c b/posix/regexec.c
index 3c46ac81dd..38b6d6719a 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -1266,10 +1266,13 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
if (type == OP_BACK_REF)
{
Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
- naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
+ if (subexp_idx < nregs)
+ naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
if (fs != NULL)
{
- if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
+ if (subexp_idx >= nregs
+ || regs[subexp_idx].rm_so == -1
+ || regs[subexp_idx].rm_eo == -1)
return -1;
else if (naccepted)
{
--
2.30.0
This diff is collapsed.
......@@ -26,6 +26,8 @@ Patch12: glibc-2.27-bits.patch
Patch13: 0001-Revert-elf-Refuse-to-dlopen-PIE-objects-BZ-24323.patch
Patch14: 0002-arm-CVE-2020-6096-fix-memcpy-and-memmove-for-negativ.patch
Patch15: 0003-arm-CVE-2020-6096-Fix-multiarch-memcpy-for-negative-.patch
Patch16: 0001-Fix-array-bounds-violation-in-regex-matcher-bug-2514.patch
Patch17: 0001-posix-Sync-regex-with-gnulib.patch
Provides: ldconfig
# The dynamic linker supports DT_GNU_HASH
......@@ -227,6 +229,8 @@ cd %{glibcsrcdir}
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%build
GCC=gcc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment