summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2022-11-11 00:05:59 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2022-11-11 00:05:59 +0000
commite63825824cc406c160ccbf2b154c5d81b168604a (patch)
tree711607e659f39bbbd8b5fe4da692e6cde659725e /src
parentf46f589c505e07541e49b37d8690cda297c41802 (diff)
downloadexim4-e63825824cc406c160ccbf2b154c5d81b168604a.tar.gz
Fix regext substring capture variables for null matches. Bug 2933
broken-by: 59d66fdc13f0
Diffstat (limited to 'src')
-rw-r--r--src/src/exim.c2
-rw-r--r--src/src/malware.c3
-rw-r--r--src/src/regex.c2
3 files changed, 6 insertions, 1 deletions
diff --git a/src/src/exim.c b/src/src/exim.c
index b3fd9eff0..47a685aa7 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -134,6 +134,8 @@ if ((yield = (res >= 0)))
PCRE2_SIZE len;
pcre2_substring_get_bynumber(md, matchnum,
(PCRE2_UCHAR **)&expand_nstring[expand_nmax], &len);
+ if (!expand_nstring[expand_nmax])
+ { expand_nstring[expand_nmax] = US""; len = 0; }
expand_nlength[expand_nmax++] = (int)len;
}
expand_nmax--;
diff --git a/src/src/malware.c b/src/src/malware.c
index 8b5ec27c4..423a5b692 100644
--- a/src/src/malware.c
+++ b/src/src/malware.c
@@ -314,7 +314,10 @@ PCRE2_UCHAR * substr = NULL;
PCRE2_SIZE slen;
if (i >= 2) /* Got it */
+ {
pcre2_substring_get_bynumber(md, 1, &substr, &slen); /* uses same ctx as md */
+ if (!substr) substr = US"";
+ }
/* pcre2_match_data_free(md); gen ctx needs no free */
return US substr;
}
diff --git a/src/src/regex.c b/src/src/regex.c
index 25496f950..b401ba0d7 100644
--- a/src/src/regex.c
+++ b/src/src/regex.c
@@ -82,7 +82,7 @@ for (pcre_list * ri = re_list_head; ri; ri = ri->next)
PCRE2_UCHAR * cstr;
PCRE2_SIZE cslen;
pcre2_substring_get_bynumber(md, nn, &cstr, &cslen); /* uses same ctx as md */
- regex_vars[nn-1] = CUS cstr;
+ regex_vars[nn-1] = cstr ? CUS cstr : CUS"";
}
return OK;