summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-07-20 14:08:49 +0000
committertb <>2022-07-20 14:08:49 +0000
commite570ac9218acd894e64a719178b58fa8f1496fe1 (patch)
treec0034efe43822782253798917829a36d819b5ff6 /src
parentdf5b87a6315647dfbae35072a0026034ebe03891 (diff)
downloadopenbsd-e570ac9218acd894e64a719178b58fa8f1496fe1.tar.gz
openbsd-e570ac9218acd894e64a719178b58fa8f1496fe1.tar.bz2
openbsd-e570ac9218acd894e64a719178b58fa8f1496fe1.zip
Validate protocols in SSL{_CTX,}_set_alpn_protos()
This wonderful API requires users to pass the protocol list in wire format. This list is then sent as part of the ClientHello. Validate it to be of the correct form. This reuses tlsext_alpn_check_format() that was split out of tlsext_alpn_server_parse(). Similar checks were introduced in OpenSSL 86a90dc7 ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_lib.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 08f2f74097..c6a01faa83 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.297 2022/07/20 13:57:49 tb Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.298 2022/07/20 14:08:49 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -162,6 +162,7 @@
162#include "dtls_locl.h" 162#include "dtls_locl.h"
163#include "ssl_locl.h" 163#include "ssl_locl.h"
164#include "ssl_sigalgs.h" 164#include "ssl_sigalgs.h"
165#include "ssl_tlsext.h"
165 166
166const char *SSL_version_str = OPENSSL_VERSION_TEXT; 167const char *SSL_version_str = OPENSSL_VERSION_TEXT;
167 168
@@ -1771,6 +1772,11 @@ SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,
1771 1772
1772 CBS_init(&cbs, protos, protos_len); 1773 CBS_init(&cbs, protos, protos_len);
1773 1774
1775 if (protos_len > 0) {
1776 if (!tlsext_alpn_check_format(&cbs))
1777 goto err;
1778 }
1779
1774 if (!CBS_stow(&cbs, &ctx->internal->alpn_client_proto_list, 1780 if (!CBS_stow(&cbs, &ctx->internal->alpn_client_proto_list,
1775 &ctx->internal->alpn_client_proto_list_len)) 1781 &ctx->internal->alpn_client_proto_list_len))
1776 goto err; 1782 goto err;
@@ -1799,6 +1805,11 @@ SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,
1799 1805
1800 CBS_init(&cbs, protos, protos_len); 1806 CBS_init(&cbs, protos, protos_len);
1801 1807
1808 if (protos_len > 0) {
1809 if (!tlsext_alpn_check_format(&cbs))
1810 goto err;
1811 }
1812
1802 if (!CBS_stow(&cbs, &ssl->internal->alpn_client_proto_list, 1813 if (!CBS_stow(&cbs, &ssl->internal->alpn_client_proto_list,
1803 &ssl->internal->alpn_client_proto_list_len)) 1814 &ssl->internal->alpn_client_proto_list_len))
1804 goto err; 1815 goto err;