From 097a0a2453f0bf87bd47b3833a71493d0c4a5140 Mon Sep 17 00:00:00 2001 From: Sven Geuer <68420948@users.noreply.github.com> Date: Sat, 2 Dec 2023 19:49:20 +0100 Subject: [PATCH] Honor -o/--host on determining the SNI host name --- ptstream.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ptstream.c b/ptstream.c index 6131fa4..1fae54c 100644 --- a/ptstream.c +++ b/ptstream.c @@ -326,11 +326,15 @@ int stream_enable_ssl(PTSTREAM *pts, const char *proxy_arg) { SSL_set_wfd (ssl, stream_get_outgoing_fd(pts)); /* Determine the host name we are connecting to */ - proxy_arg_len = strlen(proxy_arg); - peer_host = alloca(proxy_arg_len + 1); - snprintf( proxy_arg_fmt, sizeof(proxy_arg_fmt), proxy_arg[0] == '[' ? "[%%%zu[^]]]" : "%%%zu[^:]", proxy_arg_len - 1 ); - if ( sscanf( proxy_arg, proxy_arg_fmt, peer_host ) != 1 ) { - goto fail; + if (args_info.host_given ) + peer_host = args_info.host_arg; + else { + proxy_arg_len = strlen(proxy_arg); + peer_host = alloca(proxy_arg_len + 1); + snprintf( proxy_arg_fmt, sizeof(proxy_arg_fmt), proxy_arg[0] == '[' ? "[%%%zu[^]]]" : "%%%zu[^:]", proxy_arg_len - 1 ); + if ( sscanf( proxy_arg, proxy_arg_fmt, peer_host ) != 1 ) { + goto fail; + } } /* SNI support */