summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authortb <>2021-03-15 15:59:04 +0000
committertb <>2021-03-15 15:59:04 +0000
commitfc06cdeb11963e348e9787bb95689f9be064a506 (patch)
treeb29d9e1fea7b39c9759db74aee2ef863823a7455 /src/lib/libssl/ssl_lib.c
parent70029edfad38276befdaee62f4fe7e084070c0cd (diff)
downloadopenbsd-libressl-v3.2.5.tar.gz
openbsd-libressl-v3.2.5.tar.bz2
openbsd-libressl-v3.2.5.zip
Don't leave stale sequence numbers behind in ssl3_clear()libressl-v3.2.5
A TLS client doing session reuse in a certain way could run into a use-after-free. Set the sequence numbers inside ssl3_clear() to make sure this points at valid memory and do the initialization of the record layer a bit earlier so that this works as desired. Additionally, explicitly clear the sequence numbers in ssl3_free() which would have turned the use-after-free into a NULL dereference. Issue reported by Ilya Chipitsine. Fix from jsing This is errata/6.8/017_libssl.patch.sig
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 1cf64d1301..d7d3d0c051 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.234.4.1 2021/02/03 07:06:13 tb Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.234.4.2 2021/03/15 15:59:04 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 *
@@ -253,6 +253,8 @@ SSL_new(SSL_CTX *ctx)
253 goto err; 253 goto err;
254 if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL) 254 if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL)
255 goto err; 255 goto err;
256 if ((s->internal->rl = tls12_record_layer_new()) == NULL)
257 goto err;
256 258
257 s->internal->min_version = ctx->internal->min_version; 259 s->internal->min_version = ctx->internal->min_version;
258 s->internal->max_version = ctx->internal->max_version; 260 s->internal->max_version = ctx->internal->max_version;
@@ -341,9 +343,6 @@ SSL_new(SSL_CTX *ctx)
341 if (!s->method->internal->ssl_new(s)) 343 if (!s->method->internal->ssl_new(s))
342 goto err; 344 goto err;
343 345
344 if ((s->internal->rl = tls12_record_layer_new()) == NULL)
345 goto err;
346
347 s->references = 1; 346 s->references = 1;
348 s->server = (ctx->method->internal->ssl_accept == ssl_undefined_function) ? 0 : 1; 347 s->server = (ctx->method->internal->ssl_accept == ssl_undefined_function) ? 0 : 1;
349 348