From 7f8394e7c983b1c199866fc6b1c14feb857b651d Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 13 Feb 2022 12:00:55 +0000 Subject: [PATCH] Fix include_directory in redirect routers. Bug 2715 Broken-by: 10c50704c1 --- doc/doc-txt/ChangeLog | 5 +++++ src/src/parse.c | 9 ++++++--- test/confs/0313 | 4 +++- test/log/0313 | 2 ++ test/scripts/0000-Basic/0313 | 2 ++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 6cb01863d..231ec7371 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -76,6 +76,11 @@ JH/16 Debugging initiated by an ACL control now continues through into routing JH/17 The "expand" debug selector now gives more detail, specifically on the result of expansion operators and items. +JH/18 Bug 2751: Fix include_directory in redirect routers. Previously a + bad comparison between the option value and the name of the file to + be included was done, and a mismatch was wrongly identified. + 4.88 to 4.95 are affected. + Exim version 4.95 ----------------- diff --git a/src/src/parse.c b/src/src/parse.c index fcea2ea26..e30b80527 100644 --- a/src/src/parse.c +++ b/src/src/parse.c @@ -1422,8 +1422,10 @@ for (;;) if (directory) { int len = Ustrlen(directory); - uschar * p = filename + len; + uschar * p; + while (len > 0 && directory[len-1] == '/') len--; /* ignore trailing '/' */ + p = filename + len; if (Ustrncmp(filename, directory, len) != 0 || *p != '/') { *error = string_sprintf("included file %s is not in directory %s", @@ -1448,9 +1450,10 @@ for (;;) { uschar temp; int fd2; - uschar * q = p; + uschar * q = p + 1; /* skip dividing '/' */ - while (*++p && *p != '/') ; + while (*q == '/') q++; /* skip extra '/' */ + while (*++p && *p != '/') ; /* end of component */ temp = *p; *p = '\0'; diff --git a/test/confs/0313 b/test/confs/0313 index 7849526db..58fca2c84 100644 --- a/test/confs/0313 +++ b/test/confs/0313 @@ -2,7 +2,6 @@ .include DIR/aux-var/std_conf_prefix - # ----- Main settings ----- @@ -20,6 +19,9 @@ r1: r2: driver = redirect local_parts = include +.ifdef INC + include_directory = DIR/ +.endif data = :include:DIR/test-holey diff --git a/test/log/0313 b/test/log/0313 index 1e6217daf..bfece419f 100644 --- a/test/log/0313 +++ b/test/log/0313 @@ -1,3 +1,5 @@ 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@the.local.host.name U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaX-0005vi-00 == include@the.local.host.name R=r2 defer (-17): error in redirect data: included file TESTSUITE/test-holey is too big (max 1048576) 1999-03-02 09:44:33 10HmaX-0005vi-00 == filter@the.local.host.name R=r1 defer (-1): TESTSUITE/test-holey is too big (max 1048576) +1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@the.local.host.name U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaY-0005vi-00 == include@the.local.host.name R=r2 defer (-17): error in redirect data: included file TESTSUITE/test-holey is too big (max 1048576) diff --git a/test/scripts/0000-Basic/0313 b/test/scripts/0000-Basic/0313 index c118a28d8..32f288a25 100644 --- a/test/scripts/0000-Basic/0313 +++ b/test/scripts/0000-Basic/0313 @@ -10,4 +10,6 @@ close(OUT); # exim -odi filter include **** +exim -DINC -odi include +**** no_msglog_check -- 2.30.2