From b52bc06efc7a59bd262994eda285d2b125b767d7 Mon Sep 17 00:00:00 2001 From: Nigel Metheringham Date: Fri, 12 Dec 2008 14:51:47 +0000 Subject: [PATCH] Make whitespace strings compare euqal to zero. fixes: bug #749 --- doc/doc-txt/ChangeLog | 5 ++++- src/src/expand.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 1e4774067..dd9352965 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.558 2008/12/12 14:44:25 nm4 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.559 2008/12/12 14:51:47 nm4 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -83,6 +83,9 @@ NM/09 Bugzilla 787: Potential buffer overflow in string_format NM/10 Bugzilla 770: Problem on some platforms modifying the len parameter to accept() Patch provided by Maxim Dounin +NM/11 Bugzilla 749: Preserve old behaviour of blanks comparing equal to zero. + Patch provided by Phil Pennock + Exim version 4.69 ----------------- diff --git a/src/src/expand.c b/src/src/expand.c index cd84294ae..599dd9c0d 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.96 2008/08/07 11:05:03 fanf2 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.97 2008/12/12 14:51:47 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -5874,6 +5874,23 @@ systems, so we set it zero ourselves. */ errno = 0; expand_string_message = NULL; /* Indicates no error */ + +/* Before Exim 4.64, strings consisting entirely of whitespace compared +equal to 0. Unfortunately, people actually relied upon that, so preserve +the behaviour explicitly. Stripping leading whitespace is a harmless +noop change since strtol skips it anyway (provided that there is a number +to find at all). */ +if (isspace(*s)) + { + while (isspace(*s)) ++s; + if (*s == '\0') + { + DEBUG(D_expand) + debug_printf("treating blank string as number 0\n"); + return 0; + } + } + value = strtol(CS s, CSS &endptr, 10); if (endptr == s) -- 2.30.2