[exim-cvs] Lookups: dsearch subdir with leading "..". Bug 2…

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Exim Git Commits Mailing List
Fecha:  
A: exim-cvs
Asunto: [exim-cvs] Lookups: dsearch subdir with leading "..". Bug 2994
Gitweb: https://git.exim.org/exim.git/commitdiff/c1d124daf6ccb5b2ec59cf7fa6c1d76002ab0a42
Commit:     c1d124daf6ccb5b2ec59cf7fa6c1d76002ab0a42
Parent:     291dc63e2b101df566a0299d59b08fd2176e58a2
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Jun 1 16:32:22 2024 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sat Jun 1 16:32:22 2024 +0100


    Lookups: dsearch subdir with leading "..".  Bug 2994
---
 doc/doc-txt/ChangeLog                    | 3 +++
 src/src/lookups/dsearch.c                | 2 +-
 test/aux-fixed/2500.dir/..subdir/regfile | 0
 test/scripts/2500-dsearch/2500           | 1 +
 test/stdout/2500                         | 1 +
 5 files changed, 6 insertions(+), 1 deletion(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index e1cec9e15..f154430f3 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -158,6 +158,9 @@ JH/31 Bug 3027: For -bh / -bhc tests change to using the compressed form of
 JH/32 Bug 3096: MAIL before HELO/EHLO, where required by hosts_require_helo, is
       now classed as a protocol error and subject to smtp_max_synprot_errors.


+JH/33 Bug 2994: A subdir dsearch lookup should permit a directory name that starts
+      ".." and has following characters.
+


 Exim version 4.97
 -----------------
diff --git a/src/src/lookups/dsearch.c b/src/src/lookups/dsearch.c
index 22003f4e5..8258a121e 100644
--- a/src/src/lookups/dsearch.c
+++ b/src/src/lookups/dsearch.c
@@ -132,7 +132,7 @@ if (  Ulstat(filename, &statbuf) >= 0
             && S_ISDIR(statbuf.st_mode)
      && (  flags & FILTER_DIR
         || keystring[0] != '.'
-        || keystring[1] && keystring[1] != '.'
+        || keystring[1] && (keystring[1] != '.' || keystring[2])
    )  )  )  )
   {
   /* Since the filename exists in the filesystem, we can return a
diff --git a/test/aux-fixed/2500.dir/..subdir/regfile b/test/aux-fixed/2500.dir/..subdir/regfile
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/scripts/2500-dsearch/2500 b/test/scripts/2500-dsearch/2500
index 1690256da..ba524105d 100644
--- a/test/scripts/2500-dsearch/2500
+++ b/test/scripts/2500-dsearch/2500
@@ -18,6 +18,7 @@ ok,subdir:  ${lookup{TESTNUM.dir} dsearch,filter=subdir {DIR/aux-fixed}{$value}{
 fail,subdir(..):${lookup{..}          dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
 fail,subdir(.) :${lookup{.}           dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
 fail,subdir(f) :${lookup{TESTNUM.tst} dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
+ok,subdir(..d) :${lookup{..subdir}    dsearch,filter=subdir {DIR/aux-fixed/TESTNUM.dir}{$value}{FAIL}}
 fail.path:  ${lookup{TESTNUM.dir/regfile} dsearch          {DIR/aux-fixed}{$value}{FAIL}}
 ok.path:    ${lookup{TESTNUM.dir/regfile} dsearch,key=path {DIR/aux-fixed}{$value}{FAIL}}


diff --git a/test/stdout/2500 b/test/stdout/2500
index 065004bf2..dd6b4bdd6 100644
--- a/test/stdout/2500
+++ b/test/stdout/2500
@@ -15,6 +15,7 @@
> fail,subdir(..):FAIL
> fail,subdir(.) :FAIL
> fail,subdir(f) :FAIL

+> ok,subdir(..d) :..subdir
 > Failed: lookup of "2500.dir/regfile" gave DEFER: key for dsearch lookup contains a slash: 2500.dir/regfile
 > ok.path:    2500.dir/regfile

>


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/