X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/be7a578175c0e43d8b7b28d9bf5475f512d5918b..181d9bf8a602a2573d566427803a4c5288a56008:/src/src/expand.c diff --git a/src/src/expand.c b/src/src/expand.c index 0e969788a..464c6f6fc 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -571,6 +571,7 @@ static var_entry var_table[] = { { "reply_address", vtype_reply, NULL }, { "return_path", vtype_stringptr, &return_path }, { "return_size_limit", vtype_int, &bounce_return_size_limit }, + { "router_name", vtype_stringptr, &router_name }, { "runrc", vtype_int, &runrc }, { "self_hostname", vtype_stringptr, &self_hostname }, { "sender_address", vtype_stringptr, &sender_address }, @@ -667,6 +668,7 @@ static var_entry var_table[] = { { "tod_logfile", vtype_todlf, NULL }, { "tod_zone", vtype_todzone, NULL }, { "tod_zulu", vtype_todzulu, NULL }, + { "transport_name", vtype_stringptr, &transport_name }, { "value", vtype_stringptr, &lookup_value }, { "version_number", vtype_stringptr, &version_string }, { "warn_message_delay", vtype_stringptr, &warnmsg_delay }, @@ -1853,6 +1855,7 @@ if (Ustrncmp(name, "acl_", 4) == 0) /* Load args from sub array to globals, and call acl_check(). +Sub array will be corrupted on return. Returns: OK access is granted by an ACCEPT verb DISCARD access is granted by a DISCARD verb @@ -1865,13 +1868,24 @@ static int eval_acl(uschar ** sub, int nsub, uschar ** user_msgp) { int i; -uschar *dummy_log_msg; +uschar *tmp; +int sav_narg = acl_narg; +int ret; +extern int acl_where; -for (i = 1; i < nsub && sub[i]; i++) - acl_arg[i-1] = sub[i]; -acl_narg = i-1; +if(--nsub > sizeof(acl_arg)/sizeof(*acl_arg)) nsub = sizeof(acl_arg)/sizeof(*acl_arg); +for (i = 0; i < nsub && sub[i+1]; i++) + { + tmp = acl_arg[i]; + acl_arg[i] = sub[i+1]; /* place callers args in the globals */ + sub[i+1] = tmp; /* stash the old args using our caller's storage */ + } +acl_narg = i; while (i < nsub) - acl_arg[i++ - 1] = NULL; + { + sub[i+1] = acl_arg[i]; + acl_arg[i++] = NULL; + } DEBUG(D_expand) debug_printf("expanding: acl: %s arg: %s%s\n", @@ -1879,7 +1893,13 @@ DEBUG(D_expand) acl_narg>0 ? sub[1] : US"", acl_narg>1 ? " +more" : ""); -return acl_check(ACL_WHERE_EXPANSION, NULL, sub[0], user_msgp, &dummy_log_msg); +ret = acl_eval(acl_where, sub[0], user_msgp, &tmp); + +for (i = 0; i < nsub; i++) + acl_arg[i] = sub[i+1]; /* restore old args */ +acl_narg = sav_narg; + +return ret; } @@ -2130,14 +2150,13 @@ switch(cond_type) case ECOND_ACL: /* ${if acl {{name}{arg1}{arg2}...} {yes}{no}} */ { - uschar *nameargs; uschar *user_msg; BOOL cond = FALSE; int size = 0; int ptr = 0; while (isspace(*s)) s++; - if (*s++ != '{') goto COND_FAILED_CURLY_START; + if (*s++ != '{') goto COND_FAILED_CURLY_START; /*}*/ switch(read_subs(sub, sizeof(sub)/sizeof(*sub), 1, &s, yield == NULL, TRUE, US"acl")) @@ -3372,12 +3391,12 @@ if (*error == NULL) * can just let the other invalid results occur otherwise, as they have * until now. For this one case, we can coerce. */ - if (y == -1 && x == LLONG_MIN && op != '*') + if (y == -1 && x == EXIM_ARITH_MIN && op != '*') { DEBUG(D_expand) debug_printf("Integer exception dodging: " PR_EXIM_ARITH "%c-1 coerced to " PR_EXIM_ARITH "\n", - LLONG_MIN, op, LLONG_MAX); - x = LLONG_MAX; + EXIM_ARITH_MIN, op, EXIM_ARITH_MAX); + x = EXIM_ARITH_MAX; continue; } if (op == '*') @@ -5663,7 +5682,7 @@ while (*s != 0) uschar * list; int sep = 0; uschar * item; - uschar * suffix = ""; + uschar * suffix = US""; BOOL needsep = FALSE; uschar buffer[256]; @@ -5677,10 +5696,10 @@ while (*s != 0) } else switch(*arg) /* specific list-type version */ { - case 'a': t = tree_search(addresslist_anchor, sub); suffix = "_a"; break; - case 'd': t = tree_search(domainlist_anchor, sub); suffix = "_d"; break; - case 'h': t = tree_search(hostlist_anchor, sub); suffix = "_h"; break; - case 'l': t = tree_search(localpartlist_anchor, sub); suffix = "_l"; break; + case 'a': t = tree_search(addresslist_anchor, sub); suffix = US"_a"; break; + case 'd': t = tree_search(domainlist_anchor, sub); suffix = US"_d"; break; + case 'h': t = tree_search(hostlist_anchor, sub); suffix = US"_h"; break; + case 'l': t = tree_search(localpartlist_anchor, sub); suffix = US"_l"; break; default: expand_string_message = string_sprintf("bad suffix on \"list\" operator"); goto EXPAND_FAILED; @@ -5724,13 +5743,13 @@ while (*s != 0) if (*cp++ == ':') /* colon in a non-colon-sep list item, needs doubling */ { yield = string_cat(yield, &size, &ptr, US"::", 2); - item = cp; + item = (uschar *)cp; } else /* sep in item; should already be doubled; emit once */ { yield = string_cat(yield, &size, &ptr, (uschar *)tok, 1); if (*cp == sep) cp++; - item = cp; + item = (uschar *)cp; } } } @@ -6497,17 +6516,17 @@ else default: break; case 'k': - if (value > LLONG_MAX/1024 || value < LLONG_MIN/1024) errno = ERANGE; + if (value > EXIM_ARITH_MAX/1024 || value < EXIM_ARITH_MIN/1024) errno = ERANGE; else value *= 1024; endptr++; break; case 'm': - if (value > LLONG_MAX/(1024*1024) || value < LLONG_MIN/(1024*1024)) errno = ERANGE; + if (value > EXIM_ARITH_MAX/(1024*1024) || value < EXIM_ARITH_MIN/(1024*1024)) errno = ERANGE; else value *= 1024*1024; endptr++; break; case 'g': - if (value > LLONG_MAX/(1024*1024*1024) || value < LLONG_MIN/(1024*1024*1024)) errno = ERANGE; + if (value > EXIM_ARITH_MAX/(1024*1024*1024) || value < EXIM_ARITH_MIN/(1024*1024*1024)) errno = ERANGE; else value *= 1024*1024*1024; endptr++; break;