tls: use capped SNI len everywhere

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-07-04 16:52:45 +02:00
parent 034ceabe82
commit 558aae1a33

View File

@ -1199,11 +1199,11 @@ static void send_client_hello_and_alloc_hsd(tls_state_t *tls, const char *sni)
}; };
struct client_hello *record; struct client_hello *record;
int len; int len;
int sni_len = sni ? strnlen(sni, 127) : 0; int sni_len = sni ? strnlen(sni, 127 - 9) : 0;
len = sizeof(*record); len = sizeof(*record);
if (sni_len) if (sni_len)
len += 11 + strlen(sni); len += 11 + sni_len;
record = tls_get_outbuf(tls, len); record = tls_get_outbuf(tls, len);
memset(record, 0, len); memset(record, 0, len);