From: tb Date: Wed, 20 Jul 2022 14:14:34 +0000 (+0000) Subject: Copy alpn_selected using CBS X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c8b84f0c0ace39824d575cba896efefd4b83df0f;p=openbsd Copy alpn_selected using CBS ok jsing --- diff --git a/lib/libssl/ssl_tlsext.c b/lib/libssl/ssl_tlsext.c index 781d40d03a8..4ce6939c791 100644 --- a/lib/libssl/ssl_tlsext.c +++ b/lib/libssl/ssl_tlsext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_tlsext.c,v 1.122 2022/07/20 13:35:05 tb Exp $ */ +/* $OpenBSD: ssl_tlsext.c,v 1.123 2022/07/20 14:14:34 tb Exp $ */ /* * Copyright (c) 2016, 2017, 2019 Joel Sing * Copyright (c) 2017 Doug Hogan @@ -113,14 +113,15 @@ tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) s->ctx->internal->alpn_select_cb_arg); if (r == SSL_TLSEXT_ERR_OK) { - free(s->s3->alpn_selected); - if ((s->s3->alpn_selected = malloc(selected_len)) == NULL) { - s->s3->alpn_selected_len = 0; + CBS cbs; + + CBS_init(&cbs, selected, selected_len); + + if (!CBS_stow(&cbs, &s->s3->alpn_selected, + &s->s3->alpn_selected_len)) { *alert = SSL_AD_INTERNAL_ERROR; return 0; } - memcpy(s->s3->alpn_selected, selected, selected_len); - s->s3->alpn_selected_len = selected_len; return 1; }