From bf94fc838df8cb1a9557bbca6754e8a754272783 Mon Sep 17 00:00:00 2001 From: Vlad Lipskiy Date: Fri, 6 Dec 2019 20:29:50 +0300 Subject: [PATCH] Fixes C4267 MSVC warning in server_https.hpp std::min result is limited by SSL_MAX_SSL_SESSION_ID_LENGTH, which fully fits in unsigned int. So the cast won't truncate anything. --- server_https.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server_https.hpp b/server_https.hpp index f6e3b47..4150eb2 100644 --- a/server_https.hpp +++ b/server_https.hpp @@ -47,8 +47,10 @@ namespace SimpleWeb { // Creating session_id_context from address:port but reversed due to small SSL_MAX_SSL_SESSION_ID_LENGTH auto session_id_context = std::to_string(acceptor->local_endpoint().port()) + ':'; session_id_context.append(config.address.rbegin(), config.address.rend()); - SSL_CTX_set_session_id_context(context.native_handle(), reinterpret_cast(session_id_context.data()), - std::min(session_id_context.size(), SSL_MAX_SSL_SESSION_ID_LENGTH)); + const auto session_id_length = static_cast(std::min(session_id_context.size(), SSL_MAX_SSL_SESSION_ID_LENGTH)); + SSL_CTX_set_session_id_context(context.native_handle(), + reinterpret_cast(session_id_context.data()), + session_id_length); } }