X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/184e88237dea64ce48076cdd0184612d057cbafd..1d28cc061677bd07d9bed48dd84bd5c590247043:/src/src/routers/rf_get_transport.c diff --git a/src/src/routers/rf_get_transport.c b/src/src/routers/rf_get_transport.c index 2ace56322..d54e3c296 100644 --- a/src/src/routers/rf_get_transport.c +++ b/src/src/routers/rf_get_transport.c @@ -1,11 +1,11 @@ -/* $Cambridge: exim/src/src/routers/rf_get_transport.c,v 1.4 2007/01/08 10:50:20 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2007 */ +/* Copyright (c) The Exim Maintainers 2021 - 2022 */ +/* Copyright (c) University of Cambridge 1995 - 2009 */ /* See the file NOTICE for conditions of use and distribution. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "../exim.h" #include "rf_functions.h" @@ -46,11 +46,10 @@ rf_get_transport(uschar *tpname, transport_instance **tpptr, address_item *addr, { uschar *ss; BOOL expandable; -transport_instance *tp; -if (tpname == NULL) +if (!tpname) { - if (require_name == NULL) return TRUE; + if (!require_name) return TRUE; addr->basic_errno = ERRNO_BADTRANSPORT; addr->message = string_sprintf("%s unset in %s router", require_name, router_name); @@ -62,26 +61,33 @@ if (*tpptr != NULL && !expandable) return TRUE; if (expandable) { - ss = expand_string(tpname); - if (ss == NULL) + if (!(ss = expand_string(tpname))) { addr->basic_errno = ERRNO_BADTRANSPORT; addr->message = string_sprintf("failed to expand transport " "\"%s\" in %s router: %s", tpname, router_name, expand_string_message); return FALSE; } + if (is_tainted(ss)) + { + log_write(0, LOG_MAIN|LOG_PANIC, + "attempt to use tainted value '%s' from '%s' for transport", ss, tpname); + addr->basic_errno = ERRNO_BADTRANSPORT; + /* Avoid leaking info to an attacker */ + addr->message = US"internal configuration error"; + return FALSE; + } } -else ss = tpname; +else + ss = tpname; -for (tp = transports; tp != NULL; tp = tp->next) - { +for (transport_instance * tp = transports; tp; tp = tp->next) if (Ustrcmp(tp->name, ss) == 0) { DEBUG(D_route) debug_printf("set transport %s\n", ss); *tpptr = tp; return TRUE; } - } addr->basic_errno = ERRNO_BADTRANSPORT; addr->message = string_sprintf("transport \"%s\" not found in %s router", ss,