summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2022-06-07 17:26:39 +0000
committertb <>2022-06-07 17:26:39 +0000
commit4789ccad875c8376cf37b2ec8c8b83a6d9366b3e (patch)
tree7fc079bf6a5249b28eb0a0e3465c57a46638f058 /src/lib
parente2fef129d29769f5f9ba081e0b874521eab7e57d (diff)
downloadopenbsd-4789ccad875c8376cf37b2ec8c8b83a6d9366b3e.tar.gz
openbsd-4789ccad875c8376cf37b2ec8c8b83a6d9366b3e.tar.bz2
openbsd-4789ccad875c8376cf37b2ec8c8b83a6d9366b3e.zip
Unindent and simplify remove_session_lock()
ok jsing (who informs me he had the same diff in his jungle)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/ssl_sess.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 71324577b1..af53318e1e 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.110 2022/06/06 13:46:37 tb Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.111 2022/06/07 17:26:39 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 *
@@ -721,26 +721,27 @@ remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
721 SSL_SESSION *r; 721 SSL_SESSION *r;
722 int ret = 0; 722 int ret = 0;
723 723
724 if ((c != NULL) && (c->session_id_length != 0)) { 724 if (c == NULL || c->session_id_length == 0)
725 if (lck) 725 return 0;
726 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 726
727 if ((r = lh_SSL_SESSION_retrieve(ctx->internal->sessions, c)) == c) { 727 if (lck)
728 ret = 1; 728 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
729 r = lh_SSL_SESSION_delete(ctx->internal->sessions, c); 729 if ((r = lh_SSL_SESSION_retrieve(ctx->internal->sessions, c)) == c) {
730 SSL_SESSION_list_remove(ctx, c); 730 ret = 1;
731 } 731 r = lh_SSL_SESSION_delete(ctx->internal->sessions, c);
732 if (lck) 732 SSL_SESSION_list_remove(ctx, c);
733 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 733 }
734 734 if (lck)
735 if (ret) { 735 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
736 r->not_resumable = 1; 736
737 if (ctx->internal->remove_session_cb != NULL) 737 if (ret) {
738 ctx->internal->remove_session_cb(ctx, r); 738 r->not_resumable = 1;
739 SSL_SESSION_free(r); 739 if (ctx->internal->remove_session_cb != NULL)
740 } 740 ctx->internal->remove_session_cb(ctx, r);
741 } else 741 SSL_SESSION_free(r);
742 ret = 0; 742 }
743 return (ret); 743
744 return ret;
744} 745}
745 746
746void 747void