summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2021-03-21 16:56:42 +0000
committerjsing <>2021-03-21 16:56:42 +0000
commit1ecb4854420873b81260e82cb317673609053858 (patch)
tree4914e1b5a7aa46bb8329690ffcdab1c3a622e743 /src
parent61c864e66e79d4aee1e6c7cd4ccb87691e35d5e9 (diff)
downloadopenbsd-1ecb4854420873b81260e82cb317673609053858.tar.gz
openbsd-1ecb4854420873b81260e82cb317673609053858.tar.bz2
openbsd-1ecb4854420873b81260e82cb317673609053858.zip
Avoid a use-after-scope in tls13_cert_add().
A parent CBB retains a reference to a child CBB until CBB_flush() or CBB_cleanup() is called. As such, the cert_exts CBB must be at function scope. Reported by Ilya Shipitsin. ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/tls13_lib.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c
index 72c7708d91..0b3f636b93 100644
--- a/src/lib/libssl/tls13_lib.c
+++ b/src/lib/libssl/tls13_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_lib.c,v 1.56 2021/01/05 17:47:35 tb Exp $ */ 1/* $OpenBSD: tls13_lib.c,v 1.57 2021/03/21 16:56:42 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org>
@@ -429,9 +429,9 @@ tls13_ctx_free(struct tls13_ctx *ctx)
429 429
430int 430int
431tls13_cert_add(struct tls13_ctx *ctx, CBB *cbb, X509 *cert, 431tls13_cert_add(struct tls13_ctx *ctx, CBB *cbb, X509 *cert,
432 int(*build_extensions)(SSL *s, uint16_t msg_type, CBB *cbb)) 432 int (*build_extensions)(SSL *s, uint16_t msg_type, CBB *cbb))
433{ 433{
434 CBB cert_data; 434 CBB cert_data, cert_exts;
435 uint8_t *data; 435 uint8_t *data;
436 int cert_len; 436 int cert_len;
437 437
@@ -448,7 +448,6 @@ tls13_cert_add(struct tls13_ctx *ctx, CBB *cbb, X509 *cert,
448 if (!build_extensions(ctx->ssl, SSL_TLSEXT_MSG_CT, cbb)) 448 if (!build_extensions(ctx->ssl, SSL_TLSEXT_MSG_CT, cbb))
449 return 0; 449 return 0;
450 } else { 450 } else {
451 CBB cert_exts;
452 if (!CBB_add_u16_length_prefixed(cbb, &cert_exts)) 451 if (!CBB_add_u16_length_prefixed(cbb, &cert_exts))
453 return 0; 452 return 0;
454 } 453 }