summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_tlsext.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index 8c4261439a..f94469949c 100644
--- a/src/lib/libssl/ssl_tlsext.c
+++ b/src/lib/libssl/ssl_tlsext.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_tlsext.c,v 1.133 2023/04/24 15:32:31 tb Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.134 2023/04/24 16:55:06 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -2247,9 +2247,13 @@ tlsext_randomize_build_order(SSL *s)
2247 size_t idx, new_idx, psk_idx; 2247 size_t idx, new_idx, psk_idx;
2248 size_t alpn_idx, sni_idx; 2248 size_t alpn_idx, sni_idx;
2249 2249
2250 if ((s->tlsext_build_order = calloc(sizeof(*s->tlsext_build_order), 2250 free(s->tlsext_build_order);
2251 s->tlsext_build_order_len = 0;
2252
2253 if ((s->tlsext_build_order = calloc(s->tlsext_build_order_len,
2251 N_TLS_EXTENSIONS)) == NULL) 2254 N_TLS_EXTENSIONS)) == NULL)
2252 return 0; 2255 return 0;
2256 s->tlsext_build_order_len = N_TLS_EXTENSIONS;
2253 2257
2254 /* RFC 8446, section 4.2: PSK must be the last extension in the CH. */ 2258 /* RFC 8446, section 4.2: PSK must be the last extension in the CH. */
2255 psk_idx = N_TLS_EXTENSIONS - 1; 2259 psk_idx = N_TLS_EXTENSIONS - 1;
@@ -2292,6 +2296,14 @@ tlsext_linearize_build_order(SSL *s)
2292{ 2296{
2293 size_t idx; 2297 size_t idx;
2294 2298
2299 free(s->tlsext_build_order);
2300 s->tlsext_build_order_len = 0;
2301
2302 if ((s->tlsext_build_order = calloc(s->tlsext_build_order_len,
2303 N_TLS_EXTENSIONS)) == NULL)
2304 return 0;
2305 s->tlsext_build_order_len = N_TLS_EXTENSIONS;
2306
2295 for (idx = 0; idx < N_TLS_EXTENSIONS; idx++) 2307 for (idx = 0; idx < N_TLS_EXTENSIONS; idx++)
2296 s->tlsext_build_order[idx] = &tls_extensions[idx]; 2308 s->tlsext_build_order[idx] = &tls_extensions[idx];
2297 2309