Blame SOURCES/pcre-8.44-Inicialize-name-table-memory-region.patch

57161c
From f0bb9e8baf3157e0a84f484f194984295b2db23a Mon Sep 17 00:00:00 2001
57161c
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
57161c
Date: Mon, 19 Oct 2020 16:15:14 +0200
57161c
Subject: [PATCH] Inicialize name table memory region
57161c
MIME-Version: 1.0
57161c
Content-Type: text/plain; charset=UTF-8
57161c
Content-Transfer-Encoding: 8bit
57161c
57161c
Name table entry values are accessed past their ends in add_name()
57161c
when comparing the values. Also a size of the entries could grow
57161c
later. It's safer to initialize just after the allocation than to hunt
57161c
the gaps later.
57161c
57161c
Reproducer:
57161c
57161c
pcre_compile2("(?<f>)(?<fir>)", PCRE_NO_AUTO_CAPTURE | PCRE_CASELESS, &ec, &eb, &eo, NULL);
57161c
57161c
built with clang++ -fsanitize=memory -fsanitize=fuzzer-no-link.
57161c
57161c
https://bugs.exim.org/show_bug.cgi?id=2661
57161c
Signed-off-by: Petr Písař <ppisar@redhat.com>
57161c
---
57161c
 pcre_compile.c | 5 +++++
57161c
 1 file changed, 5 insertions(+)
57161c
57161c
diff --git a/pcre_compile.c b/pcre_compile.c
57161c
index 3be0fbf..75309e0 100644
57161c
--- a/pcre_compile.c
57161c
+++ b/pcre_compile.c
57161c
@@ -9423,6 +9423,11 @@ if (re == NULL)
57161c
   goto PCRE_EARLY_ERROR_RETURN;
57161c
   }
57161c
 
57161c
+/* Initialize the memory. Name table entry values are accessed past their ends
57161c
+ * (e.g. in add_name()) when comparing the values. Also a size of the entry can
57161c
+ * grow later. It's safer to initialize here than to hunt the gaps later. */
57161c
+memset(re, 0, size);
57161c
+
57161c
 /* Put in the magic number, and save the sizes, initial options, internal
57161c
 flags, and character table pointer. NULL is used for the default character
57161c
 tables. The nullpad field is at the end; it's there to help in the case when a
57161c
-- 
57161c
2.25.4
57161c