summaryrefslogtreecommitdiffstats
path: root/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2020-08-11 18:39:40 +0000
committerjsing <jsing@openbsd.org>2020-08-11 18:39:40 +0000
commit65abc581418e00fbf77f5dc6e9eeb8ea80f34312 (patch)
tree089492c10cbada6d8d5a1d2256f11c70a95329c0 /lib/libssl/ssl_lib.c
parentsetitimer(2): consolidate copyin(9), input validation, input conversion (diff)
downloadwireguard-openbsd-65abc581418e00fbf77f5dc6e9eeb8ea80f34312.tar.xz
wireguard-openbsd-65abc581418e00fbf77f5dc6e9eeb8ea80f34312.zip
In SSL_new() just 'goto err' on allocation failure.
The error path does the same as the currently duplicated code. ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/ssl_lib.c')
-rw-r--r--lib/libssl/ssl_lib.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index 5fd705c93af..bd3188cdf6d 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.219 2020/07/14 18:47:50 jsing Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.220 2020/08/11 18:39:40 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -241,7 +241,7 @@ SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth)
SSL *
SSL_new(SSL_CTX *ctx)
{
- SSL *s;
+ SSL *s;
if (ctx == NULL) {
SSLerrorx(SSL_R_NULL_SSL_CTX);
@@ -252,15 +252,10 @@ SSL_new(SSL_CTX *ctx)
return (NULL);
}
- if ((s = calloc(1, sizeof(*s))) == NULL) {
- SSLerrorx(ERR_R_MALLOC_FAILURE);
- return (NULL);
- }
- if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL) {
- free(s);
- SSLerrorx(ERR_R_MALLOC_FAILURE);
- return (NULL);
- }
+ if ((s = calloc(1, sizeof(*s))) == NULL)
+ goto err;
+ if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL)
+ goto err;
s->internal->min_version = ctx->internal->min_version;
s->internal->max_version = ctx->internal->max_version;