X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/6a8de8541c16d12eceab2c6610cd209e7641217a..54e7ce4ad20a6977ee895a358259122bf3630090:/src/src/expand.c diff --git a/src/src/expand.c b/src/src/expand.c index 9f9cbb7be..06e0eb0ce 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.107 2010/06/07 08:23:20 pdp Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.108 2010/06/07 08:42:15 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -328,9 +328,9 @@ enum { /* Type for main variable table */ typedef struct { - char *name; - int type; - void *value; + const char *name; + int type; + void *value; } var_entry; /* Type for entries pointing to address/length pairs. Not currently @@ -632,9 +632,9 @@ static BOOL malformed_header; /* For textual hashes */ -static char *hashcodes = "abcdefghijklmnopqrtsuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; +static const char *hashcodes = "abcdefghijklmnopqrtsuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"; enum { HMAC_MD5, HMAC_SHA1 }; @@ -1587,7 +1587,7 @@ while (last > first) return tod_stamp(tod_zulu); case vtype_todlf: /* Log file datestamp tod */ - return tod_stamp(tod_log_datestamp); + return tod_stamp(tod_log_datestamp_daily); case vtype_reply: /* Get reply address */ s = find_header(US"reply-to:", exists_only, newsize, TRUE, @@ -2502,7 +2502,7 @@ switch(cond_type) case ECOND_BOOL_LAX: { uschar *sub_arg[1]; - uschar *t; + uschar *t, *t2; uschar *ourname; size_t len; BOOL boolvalue = FALSE; @@ -2521,6 +2521,17 @@ switch(cond_type) t = sub_arg[0]; while (isspace(*t)) t++; len = Ustrlen(t); + if (len) + { + /* trailing whitespace: seems like a good idea to ignore it too */ + t2 = t + len - 1; + while (isspace(*t2)) t2--; + if (t2 != (t + len)) + { + *++t2 = '\0'; + len = t2 - t; + } + } DEBUG(D_expand) debug_printf("considering %s: %s\n", ourname, len ? t : US""); /* logic for the lax case from expand_check_condition(), which also does @@ -3096,7 +3107,16 @@ if (*error == NULL) int y = eval_op_unary(&s, decimal, error); if (*error != NULL) break; if (op == '*') x *= y; - else if (op == '/') x /= y; + else if (op == '/') + { + if (y == 0) + { + *error = US"divide by zero"; + x = 0; + break; + } + x /= y; + } else x %= y; } } @@ -3664,8 +3684,8 @@ while (*s != 0) if (search_find_defer) { expand_string_message = - string_sprintf("lookup of \"%s\" gave DEFER: %s", key, - search_error_message); + string_sprintf("lookup of \"%s\" gave DEFER: %s", + string_printing2(key, FALSE), search_error_message); goto EXPAND_FAILED; } if (expand_setup > 0) expand_nmax = expand_setup; @@ -5495,8 +5515,8 @@ while (*s != 0) goto EXPAND_FAILED; } - if (lookup_list[n].quote != NULL) - sub = (lookup_list[n].quote)(sub, opt); + if (lookup_list[n]->quote != NULL) + sub = (lookup_list[n]->quote)(sub, opt); else if (opt != NULL) sub = NULL; if (sub == NULL)