diff options
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 860a58ddd1..08f2f74097 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.296 2022/07/17 14:49:01 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.297 2022/07/20 13:57: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 | * |
| @@ -1763,27 +1763,23 @@ int | |||
| 1763 | SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, | 1763 | SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, |
| 1764 | unsigned int protos_len) | 1764 | unsigned int protos_len) |
| 1765 | { | 1765 | { |
| 1766 | CBS cbs; | ||
| 1766 | int failed = 1; | 1767 | int failed = 1; |
| 1767 | 1768 | ||
| 1768 | if (protos == NULL || protos_len == 0) | 1769 | if (protos == NULL) |
| 1769 | goto err; | 1770 | protos_len = 0; |
| 1770 | 1771 | ||
| 1771 | free(ctx->internal->alpn_client_proto_list); | 1772 | CBS_init(&cbs, protos, protos_len); |
| 1772 | ctx->internal->alpn_client_proto_list = NULL; | ||
| 1773 | ctx->internal->alpn_client_proto_list_len = 0; | ||
| 1774 | 1773 | ||
| 1775 | if ((ctx->internal->alpn_client_proto_list = malloc(protos_len)) | 1774 | if (!CBS_stow(&cbs, &ctx->internal->alpn_client_proto_list, |
| 1776 | == NULL) | 1775 | &ctx->internal->alpn_client_proto_list_len)) |
| 1777 | goto err; | 1776 | goto err; |
| 1778 | ctx->internal->alpn_client_proto_list_len = protos_len; | ||
| 1779 | |||
| 1780 | memcpy(ctx->internal->alpn_client_proto_list, protos, protos_len); | ||
| 1781 | 1777 | ||
| 1782 | failed = 0; | 1778 | failed = 0; |
| 1783 | 1779 | ||
| 1784 | err: | 1780 | err: |
| 1785 | /* NOTE: Return values are the reverse of what you expect. */ | 1781 | /* NOTE: Return values are the reverse of what you expect. */ |
| 1786 | return (failed); | 1782 | return failed; |
| 1787 | } | 1783 | } |
| 1788 | 1784 | ||
| 1789 | /* | 1785 | /* |
| @@ -1795,27 +1791,23 @@ int | |||
| 1795 | SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, | 1791 | SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, |
| 1796 | unsigned int protos_len) | 1792 | unsigned int protos_len) |
| 1797 | { | 1793 | { |
| 1794 | CBS cbs; | ||
| 1798 | int failed = 1; | 1795 | int failed = 1; |
| 1799 | 1796 | ||
| 1800 | if (protos == NULL || protos_len == 0) | 1797 | if (protos == NULL) |
| 1801 | goto err; | 1798 | protos_len = 0; |
| 1802 | 1799 | ||
| 1803 | free(ssl->internal->alpn_client_proto_list); | 1800 | CBS_init(&cbs, protos, protos_len); |
| 1804 | ssl->internal->alpn_client_proto_list = NULL; | ||
| 1805 | ssl->internal->alpn_client_proto_list_len = 0; | ||
| 1806 | 1801 | ||
| 1807 | if ((ssl->internal->alpn_client_proto_list = malloc(protos_len)) | 1802 | if (!CBS_stow(&cbs, &ssl->internal->alpn_client_proto_list, |
| 1808 | == NULL) | 1803 | &ssl->internal->alpn_client_proto_list_len)) |
| 1809 | goto err; | 1804 | goto err; |
| 1810 | ssl->internal->alpn_client_proto_list_len = protos_len; | ||
| 1811 | |||
| 1812 | memcpy(ssl->internal->alpn_client_proto_list, protos, protos_len); | ||
| 1813 | 1805 | ||
| 1814 | failed = 0; | 1806 | failed = 0; |
| 1815 | 1807 | ||
| 1816 | err: | 1808 | err: |
| 1817 | /* NOTE: Return values are the reverse of what you expect. */ | 1809 | /* NOTE: Return values are the reverse of what you expect. */ |
| 1818 | return (failed); | 1810 | return failed; |
| 1819 | } | 1811 | } |
| 1820 | 1812 | ||
| 1821 | /* | 1813 | /* |
