[exim-cvs] Fix argument checking for ${readsocket }

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] Fix argument checking for ${readsocket }
Gitweb: https://git.exim.org/exim.git/commitdiff/c06ddd664f4a0f6e485f6f9f6b5086aa4719a441
Commit:     c06ddd664f4a0f6e485f6f9f6b5086aa4719a441
Parent:     46d2a5e6f6e7709d172903b13945d23fc0a2c888
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Mar 26 16:05:19 2020 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu Mar 26 16:05:19 2020 +0000


    Fix argument checking for ${readsocket }
---
 doc/doc-txt/ChangeLog        | 3 +++
 src/src/expand.c             | 5 +++--
 test/scripts/0000-Basic/0373 | 4 ++++
 test/stdout/0373             | 2 ++
 4 files changed, 12 insertions(+), 2 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index be07ba6..7e5de88 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -156,6 +156,9 @@ JH/33 Fix the dsearch lookup to return an untainted result.  Previously the
       taint of the lookup key was maintained; we now regard the presence in the
       filesystem as sufficient validation.


+JH/34 Fix the readsocket expansion to not segfault when an empty "options"
+      argument is supplied.
+


 Exim version 4.93
 -----------------
diff --git a/src/src/expand.c b/src/src/expand.c
index fddad31..f937ac3 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -5335,8 +5335,9 @@ while (*s != 0)
     uschar * item;
     int sep = 0;


-    item = string_nextinlist(&list, &sep, NULL, 0);
-        if ((timeout = readconf_readtime(item, 0, FALSE)) < 0)
+    if (  !(item = string_nextinlist(&list, &sep, NULL, 0))
+       || !*item
+       || (timeout = readconf_readtime(item, 0, FALSE)) < 0)
           {
           expand_string_message = string_sprintf("bad time value %s", item);
           goto EXPAND_FAILED;
diff --git a/test/scripts/0000-Basic/0373 b/test/scripts/0000-Basic/0373
index 02cdc31..0f63cee 100644
--- a/test/scripts/0000-Basic/0373
+++ b/test/scripts/0000-Basic/0373
@@ -102,3 +102,7 @@ exim -be
 10 >>${readsocket{inet:badloop:PORT_S}{QUERY-10\n}}<<
 11 >>${readsocket{inet:thisloop:PORT_S}{QUERY-11\n}{2s:shutdown=no}}<<
 ****
+#
+exim -be
+crash-regression-check >>${readsocket{inet:127.0.0.1:PORT_N}{}{}}<<
+****
diff --git a/test/stdout/0373 b/test/stdout/0373
index b6f6f19..a4acc65 100644
--- a/test/stdout/0373
+++ b/test/stdout/0373
@@ -28,6 +28,8 @@

> 11 >>ANSWER-11

<<
>

+> Failed: bad time value NULL
+>

******** SERVER ********
Listening on TESTSUITE/test-socket ...