diff options
author | jsing <> | 2020-08-11 18:39:40 +0000 |
---|---|---|
committer | jsing <> | 2020-08-11 18:39:40 +0000 |
commit | b63bf24682853eb64f2d233908a01a013219385b (patch) | |
tree | 7810a56e02393306764ac1a5dee4cc4c2d1d8d8e /src | |
parent | 2245e65078b3dff900fed571180a355a504261d8 (diff) | |
download | openbsd-b63bf24682853eb64f2d233908a01a013219385b.tar.gz openbsd-b63bf24682853eb64f2d233908a01a013219385b.tar.bz2 openbsd-b63bf24682853eb64f2d233908a01a013219385b.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 'src')
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 5fd705c93a..bd3188cdf6 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.219 2020/07/14 18:47:50 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.220 2020/08/11 18:39:40 jsing 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 | * |
@@ -241,7 +241,7 @@ SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth) | |||
241 | SSL * | 241 | SSL * |
242 | SSL_new(SSL_CTX *ctx) | 242 | SSL_new(SSL_CTX *ctx) |
243 | { | 243 | { |
244 | SSL *s; | 244 | SSL *s; |
245 | 245 | ||
246 | if (ctx == NULL) { | 246 | if (ctx == NULL) { |
247 | SSLerrorx(SSL_R_NULL_SSL_CTX); | 247 | SSLerrorx(SSL_R_NULL_SSL_CTX); |
@@ -252,15 +252,10 @@ SSL_new(SSL_CTX *ctx) | |||
252 | return (NULL); | 252 | return (NULL); |
253 | } | 253 | } |
254 | 254 | ||
255 | if ((s = calloc(1, sizeof(*s))) == NULL) { | 255 | if ((s = calloc(1, sizeof(*s))) == NULL) |
256 | SSLerrorx(ERR_R_MALLOC_FAILURE); | 256 | goto err; |
257 | return (NULL); | 257 | if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL) |
258 | } | 258 | goto err; |
259 | if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL) { | ||
260 | free(s); | ||
261 | SSLerrorx(ERR_R_MALLOC_FAILURE); | ||
262 | return (NULL); | ||
263 | } | ||
264 | 259 | ||
265 | s->internal->min_version = ctx->internal->min_version; | 260 | s->internal->min_version = ctx->internal->min_version; |
266 | s->internal->max_version = ctx->internal->max_version; | 261 | s->internal->max_version = ctx->internal->max_version; |