diff options
| author | tb <> | 2022-07-20 14:13:13 +0000 |
|---|---|---|
| committer | tb <> | 2022-07-20 14:13:13 +0000 |
| commit | 97825e4405864a21f71e56fbfe1ef1db7f3cd998 (patch) | |
| tree | 0da012e14c59907a6e15edfa890211733df90465 /src/lib/libssl/ssl_lib.c | |
| parent | 24bbdc280b301e9f5f899bfb4001d2f584e1ad83 (diff) | |
| download | openbsd-97825e4405864a21f71e56fbfe1ef1db7f3cd998.tar.gz openbsd-97825e4405864a21f71e56fbfe1ef1db7f3cd998.tar.bz2 openbsd-97825e4405864a21f71e56fbfe1ef1db7f3cd998.zip | |
Copy alpn_client_proto_list using CBS in SSL_new()
This makes the code both shorter and safer since freeing, allocation,
and copying are handled by CBS_stow() internally.
ok jsing
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index c6a01faa83..02b4967076 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.298 2022/07/20 14:08:49 tb Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.299 2022/07/20 14:13:13 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 | * |
| @@ -240,6 +240,7 @@ SSL * | |||
| 240 | SSL_new(SSL_CTX *ctx) | 240 | SSL_new(SSL_CTX *ctx) |
| 241 | { | 241 | { |
| 242 | SSL *s; | 242 | SSL *s; |
| 243 | CBS cbs; | ||
| 243 | 244 | ||
| 244 | if (ctx == NULL) { | 245 | if (ctx == NULL) { |
| 245 | SSLerrorx(SSL_R_NULL_SSL_CTX); | 246 | SSLerrorx(SSL_R_NULL_SSL_CTX); |
| @@ -329,17 +330,11 @@ SSL_new(SSL_CTX *ctx) | |||
| 329 | ctx->internal->tlsext_supportedgroups_length; | 330 | ctx->internal->tlsext_supportedgroups_length; |
| 330 | } | 331 | } |
| 331 | 332 | ||
| 332 | if (s->ctx->internal->alpn_client_proto_list != NULL) { | 333 | CBS_init(&cbs, ctx->internal->alpn_client_proto_list, |
| 333 | s->internal->alpn_client_proto_list = | 334 | ctx->internal->alpn_client_proto_list_len); |
| 334 | malloc(s->ctx->internal->alpn_client_proto_list_len); | 335 | if (!CBS_stow(&cbs, &s->internal->alpn_client_proto_list, |
| 335 | if (s->internal->alpn_client_proto_list == NULL) | 336 | &s->internal->alpn_client_proto_list_len)) |
| 336 | goto err; | 337 | goto err; |
| 337 | memcpy(s->internal->alpn_client_proto_list, | ||
| 338 | s->ctx->internal->alpn_client_proto_list, | ||
| 339 | s->ctx->internal->alpn_client_proto_list_len); | ||
| 340 | s->internal->alpn_client_proto_list_len = | ||
| 341 | s->ctx->internal->alpn_client_proto_list_len; | ||
| 342 | } | ||
| 343 | 338 | ||
| 344 | s->verify_result = X509_V_OK; | 339 | s->verify_result = X509_V_OK; |
| 345 | 340 | ||
