summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2020-09-24 18:12:01 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2020-09-24 18:12:01 +0000
commit65adc085a9db8248e0b8cf31c20cd3b3febe7618 (patch)
tree1b1ad0c366d65daa5365ba03a9dbbaf0ee47f9c2
parent2632ec70093defec640d16fb20cecf62da26cd81 (diff)
Simplify the cleanup of init_buf via a ssl3_release_init_buffer() function.
ok beck@ inoguchi@ tb@
-rw-r--r--lib/libssl/ssl_both.c12
-rw-r--r--lib/libssl/ssl_clnt.c8
-rw-r--r--lib/libssl/ssl_lib.c7
-rw-r--r--lib/libssl/ssl_locl.h3
-rw-r--r--lib/libssl/ssl_srvr.c8
5 files changed, 22 insertions, 16 deletions
diff --git a/lib/libssl/ssl_both.c b/lib/libssl/ssl_both.c
index dff44ecd415..5da450b5cec 100644
--- a/lib/libssl/ssl_both.c
+++ b/lib/libssl/ssl_both.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_both.c,v 1.19 2020/09/24 17:59:54 jsing Exp $ */
+/* $OpenBSD: ssl_both.c,v 1.20 2020/09/24 18:12:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -686,6 +686,16 @@ err:
return (0);
}
+void
+ssl3_release_init_buffer(SSL *s)
+{
+ BUF_MEM_free(s->internal->init_buf);
+ s->internal->init_buf = NULL;
+ s->internal->init_msg = NULL;
+ s->internal->init_num = 0;
+ s->internal->init_off = 0;
+}
+
int
ssl3_setup_read_buffer(SSL *s)
{
diff --git a/lib/libssl/ssl_clnt.c b/lib/libssl/ssl_clnt.c
index d62928a093f..f11dcaa1074 100644
--- a/lib/libssl/ssl_clnt.c
+++ b/lib/libssl/ssl_clnt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_clnt.c,v 1.72 2020/09/17 15:23:29 jsing Exp $ */
+/* $OpenBSD: ssl_clnt.c,v 1.73 2020/09/24 18:12:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -588,10 +588,8 @@ ssl3_connect(SSL *s)
goto end;
}
- if (!SSL_IS_DTLS(s)) {
- BUF_MEM_free(s->internal->init_buf);
- s->internal->init_buf = NULL;
- }
+ if (!SSL_IS_DTLS(s))
+ ssl3_release_init_buffer(s);
ssl_free_wbio_buffer(s);
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index 65d5614bfbf..6e375e1c099 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.233 2020/09/19 10:17:56 tb Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.234 2020/09/24 18:12:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -196,8 +196,7 @@ SSL_clear(SSL *s)
tls13_ctx_free(s->internal->tls13);
s->internal->tls13 = NULL;
- BUF_MEM_free(s->internal->init_buf);
- s->internal->init_buf = NULL;
+ ssl3_release_init_buffer(s);
ssl_clear_cipher_state(s);
@@ -531,7 +530,7 @@ SSL_free(SSL *s)
tls13_ctx_free(s->internal->tls13);
- BUF_MEM_free(s->internal->init_buf);
+ ssl3_release_init_buffer(s);
sk_SSL_CIPHER_free(s->cipher_list);
sk_SSL_CIPHER_free(s->internal->cipher_list_tls13);
diff --git a/lib/libssl/ssl_locl.h b/lib/libssl/ssl_locl.h
index d4ba7f66d4a..9a9ef592826 100644
--- a/lib/libssl/ssl_locl.h
+++ b/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_locl.h,v 1.294 2020/09/24 17:59:54 jsing Exp $ */
+/* $OpenBSD: ssl_locl.h,v 1.295 2020/09/24 18:12:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1221,6 +1221,7 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt,
STACK_OF(SSL_CIPHER) *srvr);
int ssl3_setup_buffers(SSL *s);
int ssl3_setup_init_buffer(SSL *s);
+void ssl3_release_init_buffer(SSL *s);
int ssl3_setup_read_buffer(SSL *s);
int ssl3_setup_write_buffer(SSL *s);
void ssl3_release_buffer(SSL3_BUFFER_INTERNAL *b);
diff --git a/lib/libssl/ssl_srvr.c b/lib/libssl/ssl_srvr.c
index f69be70f04a..0f448a2d38f 100644
--- a/lib/libssl/ssl_srvr.c
+++ b/lib/libssl/ssl_srvr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_srvr.c,v 1.84 2020/09/17 15:23:29 jsing Exp $ */
+/* $OpenBSD: ssl_srvr.c,v 1.85 2020/09/24 18:12:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -691,10 +691,8 @@ ssl3_accept(SSL *s)
goto end;
}
- if (!SSL_IS_DTLS(s)) {
- BUF_MEM_free(s->internal->init_buf);
- s->internal->init_buf = NULL;
- }
+ if (!SSL_IS_DTLS(s))
+ ssl3_release_init_buffer(s);
/* remove buffering on output */
ssl_free_wbio_buffer(s);