aboutsummaryrefslogtreecommitdiffstats
path: root/main/opensmtpd/CVE-2020-35679.patch
blob: 6746c27447720266e0911b64f6df9844ecbab5f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 79a034b4aed29e965f45a13409268290c9910043 Mon Sep 17 00:00:00 2001
From: martijn <martijn@openbsd.org>
Date: Wed, 23 Dec 2020 08:12:14 +0000
Subject: [PATCH] Use regfree after we're done with preg.

From gilles@
---
 smtpd/table.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index b79451caadd4..1d82d88b81a4 100644
--- a/smtpd/table.c
+++ b/smtpd/table.c
@@ -464,6 +464,7 @@ table_regex_match(const char *string, const char *pattern)
 {
 	regex_t preg;
 	int	cflags = REG_EXTENDED|REG_NOSUB;
+	int ret;
 
 	if (strncmp(pattern, "(?i)", 4) == 0) {
 		cflags |= REG_ICASE;
@@ -473,7 +474,11 @@ table_regex_match(const char *string, const char *pattern)
 	if (regcomp(&preg, pattern, cflags) != 0)
 		return (0);
 
-	if (regexec(&preg, string, 0, NULL, 0) != 0)
+	ret = regexec(&preg, string, 0, NULL, 0);
+
+	regfree(&preg);
+
+	if (ret != 0)
 		return (0);
 
 	return (1);