diff options
| author | jsing <> | 2021-03-21 16:56:42 +0000 |
|---|---|---|
| committer | jsing <> | 2021-03-21 16:56:42 +0000 |
| commit | 445ef5f4262e1c57b0671aeed689045736f9113f (patch) | |
| tree | 4914e1b5a7aa46bb8329690ffcdab1c3a622e743 /src | |
| parent | a743462ddbd1c456c9e01a4546f33ad2dff15abd (diff) | |
| download | openbsd-445ef5f4262e1c57b0671aeed689045736f9113f.tar.gz openbsd-445ef5f4262e1c57b0671aeed689045736f9113f.tar.bz2 openbsd-445ef5f4262e1c57b0671aeed689045736f9113f.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.c | 7 |
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 | ||
| 430 | int | 430 | int |
| 431 | tls13_cert_add(struct tls13_ctx *ctx, CBB *cbb, X509 *cert, | 431 | tls13_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 | } |
