Mercurial > dropbear
diff cli-tcpfwd.c @ 1219:84cf9062718d coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Dec 2015 22:24:34 +0800 |
parents | d058e15ea213 |
children | 888e3d17e962 2bb4c662d1c2 |
line wrap: on
line diff
--- a/cli-tcpfwd.c Wed Dec 02 22:37:51 2015 +0800 +++ b/cli-tcpfwd.c Tue Dec 15 22:24:34 2015 +0800 @@ -60,6 +60,23 @@ }; #endif +#ifdef ENABLE_CLI_ANYTCPFWD +static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2); +void fwd_failed(const char* format, ...) +{ + va_list param; + va_start(param, format); + + if (cli_opts.exit_on_fwd_failure) { + _dropbear_exit(EXIT_FAILURE, format, param); + } else { + _dropbear_log(LOG_WARNING, format, param); + } + + va_end(param); +} +#endif + #ifdef ENABLE_CLI_LOCALTCPFWD void setup_localtcp() { m_list_elem *iter; @@ -75,7 +92,7 @@ fwd->connectaddr, fwd->connectport); if (ret == DROPBEAR_FAILURE) { - dropbear_log(LOG_WARNING, "Failed local port forward %s:%d:%s:%d", + fwd_failed("Failed local port forward %s:%d:%s:%d", fwd->listenaddr, fwd->listenport, fwd->connectaddr, @@ -181,7 +198,10 @@ struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item; if (!fwd->have_reply) { fwd->have_reply = 1; - dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", fwd->listenport, fwd->connectaddr, fwd->connectport); + fwd_failed("Remote TCP forward request failed (port %d -> %s:%d)", + fwd->listenport, + fwd->connectaddr, + fwd->connectport); return; } }