[exim-cvs] Lookups: fix $local_part_data for a match on a fi…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Lookups: fix $local_part_data for a match on a filename list element. Bug 2691
Gitweb: https://git.exim.org/exim.git/commitdiff/0c70e694cf1a703798c0778a3236079e1b25c91d
Commit:     0c70e694cf1a703798c0778a3236079e1b25c91d
Parent:     37a81ae7317bb78b2ff152821930c2ff0873512b
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Fri Jan 29 16:34:27 2021 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Fri Jan 29 18:26:57 2021 +0000


    Lookups: fix $local_part_data for a match on a filename list element.  Bug 2691
---
 doc/doc-txt/ChangeLog        |  4 ++++
 src/src/match.c              | 17 +++++++++++------
 test/aux-fixed/0134.listL    |  1 +
 test/confs/0134              | 15 +++++++++++++++
 test/log/0134                |  3 +++
 test/mail/0134.directfile    | 14 ++++++++++++++
 test/scripts/0000-Basic/0134 |  4 ++++
 7 files changed, 52 insertions(+), 6 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index b209912..e1a2fa3 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -184,6 +184,10 @@ JH/38 When logging an AUTH failure, as server, do not include sensitive
       information. Previously, the credentials would be included if given
       as part of the AUTH command line and an ACL denied authentidcation.


+JH/39 Bug 2691: fix $local_part_data.  When the matching list element
+      referred to a file, bad data was returned.  This likely also affected
+      $domain_part_data.
+



 Exim version 4.94
diff --git a/src/src/match.c b/src/src/match.c
index 597b633..73cdab0 100644
--- a/src/src/match.c
+++ b/src/src/match.c
@@ -809,19 +809,19 @@ while ((sss = string_nextinlist(&list, &sep, NULL, 0)))
         sss = ss + 1;
         }


-      ss = filebuffer + Ustrlen(filebuffer);             /* trailing space */
+      ss = filebuffer + Ustrlen(filebuffer);        /* trailing space */
       while (ss > filebuffer && isspace(ss[-1])) ss--;
       *ss = 0;


       ss = filebuffer;
-      while (isspace(*ss)) ss++;                         /* leading space */
+      while (isspace(*ss)) ss++;            /* leading space */


-      if (*ss == 0) continue;                            /* ignore empty */
+      if (!*ss) continue;                /* ignore empty */


-      file_yield = yield;                                /* positive yield */
-      sss = ss;                                          /* for debugging */
+      file_yield = yield;                /* positive yield */
+      sss = ss;                        /* for debugging */


-      if (*ss == '!')                                    /* negation */
+      if (*ss == '!')                    /* negation */
         {
         file_yield = (file_yield == OK)? FAIL : OK;
         while (isspace((*(++ss))));
@@ -833,6 +833,11 @@ while ((sss = string_nextinlist(&list, &sep, NULL, 0)))
       (void)fclose(f);
       HDEBUG(D_lists) debug_printf("%s %s (matched \"%s\" in %s)\n", ot,
         yield == OK ? "yes" : "no", sss, filename);
+
+      /* The "pattern" being matched came from the file; we use a stack-local.
+      Copy it to allocated memory now we know it matched. */
+
+      if (valueptr) *valueptr = string_copy(ss);
       return file_yield;


         case DEFER:
diff --git a/test/aux-fixed/0134.listL b/test/aux-fixed/0134.listL
new file mode 100644
index 0000000..c3be4e8
--- /dev/null
+++ b/test/aux-fixed/0134.listL
@@ -0,0 +1 @@
+direct_file_user
diff --git a/test/confs/0134 b/test/confs/0134
index 9530df6..3376f05 100644
--- a/test/confs/0134
+++ b/test/confs/0134
@@ -45,6 +45,14 @@ smartuser:
   retry_use_local_part
   transport = appendfile


+smartuser_direct:
+  driver = accept
+  domains = test.ex
+  headers_add = "smartuser: dd=$domain_data lpd=$local_part_data"
+  local_parts = DIR/aux-fixed/TESTNUM.listL
+  retry_use_local_part
+  transport = directfile
+
 default2:
   driver = accept
   headers_add = router: defaulted
@@ -71,6 +79,13 @@ appendfile:
          ${if eq {$local_part}{userx}{lc-userx}{\
          $local_part}}}}}}


+directfile:
+  driver = appendfile
+  user = CALLER
+  headers_add = "domain_data: $domain_data\n\
+                 local_part_data: $local_part_data"
+  file = DIR/test-mail/directfile
+
 pipe:
   driver = pipe
   command = /bin/sh -c "echo $local_part $domain >DIR/test-mail/$local_part"
diff --git a/test/log/0134 b/test/log/0134
index 1d4707f..956558f 100644
--- a/test/log/0134
+++ b/test/log/0134
@@ -23,3 +23,6 @@
 1999-03-02 09:44:33 10HmbE-0005vi-00 <= CALLER@??? U=CALLER P=local S=sss
 1999-03-02 09:44:33 10HmbE-0005vi-00 => PIPE <PIPE@???> R=topipe T=pipe
 1999-03-02 09:44:33 10HmbE-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbF-0005vi-00 <= CALLER@??? U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmbF-0005vi-00 => direct_file_user <direct_file_user@???> R=smartuser_direct T=directfile
+1999-03-02 09:44:33 10HmbF-0005vi-00 Completed
diff --git a/test/mail/0134.directfile b/test/mail/0134.directfile
new file mode 100644
index 0000000..aa9475d
--- /dev/null
+++ b/test/mail/0134.directfile
@@ -0,0 +1,14 @@
+From CALLER@??? Tue Mar 02 09:44:33 1999
+Received: from CALLER by the.local.host.name with local (Exim x.yz)
+    (envelope-from <CALLER@???>)
+    id 10HmbF-0005vi-00
+    for direct_file_user@???; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmbF-0005vi-00@???>
+From: CALLER_NAME <CALLER@???>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+smartuser: dd=test.ex lpd=direct_file_user
+domain_data: test.ex
+local_part_data: direct_file_user
+
+Test use of filename in local_part list
+
diff --git a/test/scripts/0000-Basic/0134 b/test/scripts/0000-Basic/0134
index 76c1f82..15f3b05 100644
--- a/test/scripts/0000-Basic/0134
+++ b/test/scripts/0000-Basic/0134
@@ -31,3 +31,7 @@ exim -odi PIPE@???
 Test to uppercased piped address.
 .
 ****
+exim -odi direct_file_user@???
+Test use of filename in local_part list
+.
+****