From e2cb43477784f1b337f440fb26efcfe03117cb94 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Wed, 5 Oct 2016 18:11:39 +0300 Subject: [PATCH] Stream ssl_preread: fixed $ssl_preread_server_name variable. Made sure to set the variable length only after successful SNI parsing. --- src/stream/ngx_stream_ssl_preread_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stream/ngx_stream_ssl_preread_module.c b/src/stream/ngx_stream_ssl_preread_module.c index 166c09395..e26c51891 100644 --- a/src/stream/ngx_stream_ssl_preread_module.c +++ b/src/stream/ngx_stream_ssl_preread_module.c @@ -333,11 +333,12 @@ ngx_stream_ssl_preread_parse_record(ngx_stream_ssl_preread_ctx_t *ctx, return NGX_ERROR; } - ctx->host.len = size; dst = ctx->host.data; break; case sw_sni_host: + ctx->host.len = (p[1] << 8) + p[2]; + ngx_log_debug1(NGX_LOG_DEBUG_STREAM, ctx->log, 0, "ssl preread: SNI hostname \"%V\"", &ctx->host); return NGX_OK;