summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2023-09-11 15:50:35 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2023-09-11 15:50:35 +0100
commitb015574531cf18b2126edb9da5a99dad659207dd (patch)
tree5e503b54499072897c1f57077e794e5d2b8d82ca
parentcf1e30bc975d646511945e3dd3538fb97637559d (diff)
Fix ${tr...} and empty-strings. Bug 3023
-rw-r--r--doc/doc-txt/ChangeLog3
-rw-r--r--src/src/expand.c9
-rw-r--r--test/scripts/0000-Basic/00021
-rw-r--r--test/stdout/00021
4 files changed, 9 insertions, 5 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index b1b79c240..5fcc8ab11 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -190,6 +190,9 @@ JH/38 Taint-track intermediate values from the peer in multi-stage authentation
this resulted in behaviour of LOGIN vs. PLAIN being inconsistent under
bad coding of authenticators.
+JH/39 Bug 3023: Fix crash induced by some combinations of zero-length strings
+ and ${tr...}. Found and diagnosed by Heiko Schlichting.
+
Exim version 4.96
-----------------
diff --git a/src/src/expand.c b/src/src/expand.c
index b4a76b3e7..aa8bfe643 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -5807,16 +5807,15 @@ while (*s)
case 3: goto EXPAND_FAILED;
}
- yield = string_cat(yield, sub[0]);
- o2m = Ustrlen(sub[2]) - 1;
-
- if (o2m >= 0) for (; oldptr < yield->ptr; oldptr++)
+ if ( (yield = string_cat(yield, sub[0]))
+ && (o2m = Ustrlen(sub[2]) - 1) >= 0)
+ for (; oldptr < yield->ptr; oldptr++)
{
uschar * m = Ustrrchr(sub[1], yield->s[oldptr]);
if (m)
{
int o = m - sub[1];
- yield->s[oldptr] = sub[2][(o < o2m)? o : o2m];
+ yield->s[oldptr] = sub[2][o < o2m ? o : o2m];
}
}
diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002
index dab982253..b4f2341bb 100644
--- a/test/scripts/0000-Basic/0002
+++ b/test/scripts/0000-Basic/0002
@@ -714,6 +714,7 @@ abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
abcdea a z ${tr{abcdea}{a}{z}}
abcdea a ${tr{abcdea}{a}{}}
abcdea abc z ${tr{abcdea}{abc}{z}}
+(null) '${sg{$header_foobar:${tr{}{}{foobar}}}{}{}}'
# Boolean
"TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
diff --git a/test/stdout/0002 b/test/stdout/0002
index 5b9de8e5e..2d7c82838 100644
--- a/test/stdout/0002
+++ b/test/stdout/0002
@@ -696,6 +696,7 @@ newline tab\134backslash ~tilde\177DEL\200\201.
> abcdea a z zbcdez
> abcdea a abcdea
> abcdea abc z zzzdez
+> (null) ''
>
> # Boolean
> "TrUe" true EXPECT: true