summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2007-01-08 11:56:41 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2007-01-08 11:56:41 +0000
commit5dd1517fd7fd1ebbfdfaafaaccd5689169dbd301 (patch)
treef3170c3067971d21e1fc5ec2df749c421146b550
parent184e88237dea64ce48076cdd0184612d057cbafd (diff)
Cast empty string to zero for numerical comparions and treat all numbers
as decimal.
-rw-r--r--doc/doc-txt/ChangeLog22
-rw-r--r--src/src/expand.c17
-rwxr-xr-xtest/runtest4
-rw-r--r--test/scripts/0000-Basic/00026
-rw-r--r--test/stdout/00026
5 files changed, 48 insertions, 7 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index fbe0549c8..668afc356 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,8 +1,28 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.450 2007/01/02 11:25:00 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.451 2007/01/08 11:56:41 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
+Exim version 4.66
+-----------------
+
+PH/01 Two more bugs that were introduced by 4.64/PH/07, in addition to the one
+ fixed by 4.65/MH/01 (is this a record?) are fixed:
+
+ (i) An empty string was always treated as zero by the numeric comparison
+ operators. This behaviour has been restored.
+
+ (ii) It is documented that the numeric comparison operators always treat
+ their arguments as decimal numbers. This was broken in that numbers
+ starting with 0 were being interpreted as octal.
+
+ While fixing these problems I realized that there was another issue that
+ hadn't been noticed. Values of message_size_limit (both the global option
+ and the transport option) were treated as octal if they started with 0.
+ The documentation was vague. These values are now always treated as
+ decimal, and I will make that clear in the documentation.
+
+
Exim version 4.65
-----------------
diff --git a/src/src/expand.c b/src/src/expand.c
index 83cd74962..c7a4749d9 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.75 2007/01/08 10:50:18 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.76 2007/01/08 11:56:41 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -1988,8 +1988,17 @@ switch(cond_type)
if (!isalpha(name[0]) && yield != NULL)
{
- num[i] = expand_string_integer(sub[i], FALSE);
- if (expand_string_message != NULL) return NULL;
+ if (sub[i][0] == 0)
+ {
+ num[i] = 0;
+ DEBUG(D_expand)
+ debug_printf("empty string cast to zero for numerical comparison\n");
+ }
+ else
+ {
+ num[i] = expand_string_integer(sub[i], FALSE);
+ if (expand_string_message != NULL) return NULL;
+ }
}
}
@@ -5499,7 +5508,7 @@ systems, so we set it zero ourselves. */
errno = 0;
expand_string_message = NULL; /* Indicates no error */
-value = strtol(CS s, CSS &endptr, 0);
+value = strtol(CS s, CSS &endptr, 10);
if (endptr == s)
{
diff --git a/test/runtest b/test/runtest
index aee2697ad..ec1e8280a 100755
--- a/test/runtest
+++ b/test/runtest
@@ -1,6 +1,6 @@
#! /usr/bin/perl -w
-# $Cambridge: exim/test/runtest,v 1.19 2006/11/14 16:40:36 ph10 Exp $
+# $Cambridge: exim/test/runtest,v 1.20 2007/01/08 11:56:41 ph10 Exp $
###############################################################################
# This is the controlling script for the "new" test suite for Exim. It should #
@@ -23,7 +23,7 @@ use Socket;
# Start by initializing some global variables
-$testversion = "4.64 (05-Sep-06)";
+$testversion = "4.66 (08-Jan-07)";
$cf = "bin/cf";
$cr = "\r";
diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002
index 760ffb358..c31b9232f 100644
--- a/test/scripts/0000-Basic/0002
+++ b/test/scripts/0000-Basic/0002
@@ -237,6 +237,12 @@ mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
5>3z: ${if >{5 } {3z }{y}{n}}
5>a: ${if >{ 5 } {a}{y}{n}}
+>0: ${if > {}{0}{y}{n}}
+=: ${if = {}{}{y}{n}}
+-2<: ${if < {-2}{}{y}{n}}
+08>07: ${if > {08}{07}{y}{n}}
+011=11: ${if = {011}{11}{y}{n}}
+
def:y ${if def:tod_log{y}{n}}
def:n ${if def:host{y}{n}}
def:f ${if def:post{y}{n}}
diff --git a/test/stdout/0002 b/test/stdout/0002
index a202d1ebb..a4e6feb2f 100644
--- a/test/stdout/0002
+++ b/test/stdout/0002
@@ -218,6 +218,12 @@
> Failed: invalid integer "3z "
> Failed: integer expected but "a" found
>
+> >0: n
+> =: y
+> -2<: y
+> 08>07: y
+> 011=11: y
+>
> def:y y
> def:n n
> Failed: unknown variable "post" after "def:"