4bccc70e07
Fixes CVE-2022-3559: A vulnerability was found in Exim and classified as problematic. This issue affects some unknown processing of the component Regex Handler. The manipulation leads to use after free. The name of the patch is 4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2. It is recommended to apply a patch to fix this issue. The identifier VDB-211073 was assigned to this vulnerability. The upstream patch does not apply to 4.96, so use the backported patches from Debian. Amazingly, the patch needs 3 additional patches to unbreak builds without "WITH_CONTENT_SCAN" (default in Buildroot), so add those as well. Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
140 lines
4.3 KiB
Diff
140 lines
4.3 KiB
Diff
From 158dff9936e36a2d31d037d3988b9353458d6471 Mon Sep 17 00:00:00 2001
|
|
From: Jeremy Harris <jgh146exb@wizmail.org>
|
|
Date: Wed, 31 Aug 2022 17:17:59 +0100
|
|
Subject: [PATCH] Fix non-WITH_CONTENT_SCAN build (2)
|
|
|
|
Broken-by: d8ecc7bf97
|
|
|
|
[Upstream: https://sources.debian.org/data/main/e/exim4/4.96-9/debian/patches/75_10-Fix-non-WITH_CONTENT_SCAN-build-2.patch]
|
|
[Peter: drop Changelog hunk]
|
|
Signed-off-by: Peter Korsgaard <peter@korsgard.com>
|
|
---
|
|
src/exim.c | 13 +------------
|
|
src/functions.h | 2 +-
|
|
src/globals.h | 2 +-
|
|
src/regex.c | 10 ++++++++++
|
|
src/smtp_in.c | 2 ++
|
|
5 files changed, 15 insertions(+), 14 deletions(-)
|
|
|
|
--- a/src/exim.c
|
|
+++ b/src/exim.c
|
|
@@ -1677,21 +1677,10 @@
|
|
if ((s = expand_string(big_buffer))) printf("%s\n", CS s);
|
|
else printf("Failed: %s\n", expand_string_message);
|
|
}
|
|
|
|
|
|
-/* reset regex expansion variables */
|
|
-void
|
|
-regex_vars_clear(void)
|
|
-{
|
|
-regex_match_string = NULL;
|
|
-for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
|
|
-}
|
|
-
|
|
-
|
|
-
|
|
-
|
|
|
|
/*************************************************
|
|
* Entry point and high-level code *
|
|
*************************************************/
|
|
|
|
@@ -6085,17 +6074,17 @@
|
|
deliver_domain_orig = NULL;
|
|
deliver_host = deliver_host_address = NULL;
|
|
dnslist_domain = dnslist_matched = NULL;
|
|
#ifdef WITH_CONTENT_SCAN
|
|
malware_name = NULL;
|
|
+ regex_vars_clear();
|
|
#endif
|
|
callout_address = NULL;
|
|
sending_ip_address = NULL;
|
|
deliver_localpart_data = deliver_domain_data =
|
|
recipient_data = sender_data = NULL;
|
|
acl_var_m = NULL;
|
|
- regex_vars_clear();
|
|
|
|
store_reset(reset_point);
|
|
}
|
|
|
|
exim_exit(EXIT_SUCCESS); /* Never returns */
|
|
--- a/src/functions.h
|
|
+++ b/src/functions.h
|
|
@@ -432,15 +432,15 @@
|
|
extern BOOL receive_msg(BOOL);
|
|
extern int_eximarith_t receive_statvfs(BOOL, int *);
|
|
extern void receive_swallow_smtp(void);
|
|
#ifdef WITH_CONTENT_SCAN
|
|
extern int regex(const uschar **);
|
|
+extern void regex_vars_clear(void);
|
|
#endif
|
|
extern BOOL regex_match(const pcre2_code *, const uschar *, int, uschar **);
|
|
extern BOOL regex_match_and_setup(const pcre2_code *, const uschar *, int, int);
|
|
extern const pcre2_code *regex_must_compile(const uschar *, BOOL, BOOL);
|
|
-extern void regex_vars_clear(void);
|
|
extern void retry_add_item(address_item *, uschar *, int);
|
|
extern BOOL retry_check_address(const uschar *, host_item *, uschar *, BOOL,
|
|
uschar **, uschar **);
|
|
extern retry_config *retry_find_config(const uschar *, const uschar *, int, int);
|
|
extern BOOL retry_ultimate_address_timeout(uschar *, const uschar *,
|
|
--- a/src/globals.h
|
|
+++ b/src/globals.h
|
|
@@ -895,16 +895,16 @@
|
|
#ifndef DISABLE_PIPE_CONNECT
|
|
extern const pcre2_code *regex_EARLY_PIPE; /* For recognizing PIPE_CONNCT */
|
|
#endif
|
|
extern const pcre2_code *regex_ismsgid; /* Compiled r.e. for message ID */
|
|
extern const pcre2_code *regex_smtp_code; /* For recognizing SMTP codes */
|
|
-extern const uschar *regex_vars[]; /* $regexN variables */
|
|
#ifdef WHITELIST_D_MACROS
|
|
extern const pcre2_code *regex_whitelisted_macro; /* For -D macro values */
|
|
#endif
|
|
#ifdef WITH_CONTENT_SCAN
|
|
extern uschar *regex_match_string; /* regex that matched a line (regex ACL condition) */
|
|
+extern const uschar *regex_vars[];
|
|
#endif
|
|
extern int remote_delivery_count; /* Number of remote addresses */
|
|
extern int remote_max_parallel; /* Maximum parallel delivery */
|
|
extern uschar *remote_sort_domains; /* Remote domain sorting order */
|
|
extern retry_config *retries; /* Chain of retry config information */
|
|
--- a/src/regex.c
|
|
+++ b/src/regex.c
|
|
@@ -95,10 +95,20 @@
|
|
pcre2_match_data_free(md);
|
|
return FAIL;
|
|
}
|
|
|
|
|
|
+/* reset expansion variables */
|
|
+void
|
|
+regex_vars_clear(void)
|
|
+{
|
|
+regex_match_string = NULL;
|
|
+for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
|
|
+}
|
|
+
|
|
+
|
|
+
|
|
int
|
|
regex(const uschar ** listptr)
|
|
{
|
|
unsigned long mbox_size;
|
|
FILE * mbox_file;
|
|
--- a/src/smtp_in.c
|
|
+++ b/src/smtp_in.c
|
|
@@ -2155,11 +2155,13 @@
|
|
prdr_requested = FALSE;
|
|
#endif
|
|
#ifdef SUPPORT_I18N
|
|
message_smtputf8 = FALSE;
|
|
#endif
|
|
+#ifdef WITH_CONTENT_SCAN
|
|
regex_vars_clear();
|
|
+#endif
|
|
body_linecount = body_zerocount = 0;
|
|
|
|
lookup_value = NULL; /* Can be set by ACL */
|
|
sender_rate = sender_rate_limit = sender_rate_period = NULL;
|
|
ratelimiters_mail = NULL; /* Updated by ratelimit ACL condition */
|