From b56105c2617b86206d3688dd7940aa6e553af6e1 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 25 Oct 2021 10:01:46 +0000 Subject: Fold SSL_SESSION_INTERNAL back into SSL_SESSION. ok beck@ tb@ --- src/lib/libssl/ssl_sess.c | 72 ++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) (limited to 'src/lib/libssl/ssl_sess.c') diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c index 4e798e08f0..2fa6af4564 100644 --- a/src/lib/libssl/ssl_sess.c +++ b/src/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.105 2021/09/08 17:27:33 tb Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.106 2021/10/25 10:01:46 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -186,13 +186,13 @@ SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg) { - return (CRYPTO_set_ex_data(&s->internal->ex_data, idx, arg)); + return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_SESSION_get_ex_data(const SSL_SESSION *s, int idx) { - return (CRYPTO_get_ex_data(&s->internal->ex_data, idx)); + return (CRYPTO_get_ex_data(&s->ex_data, idx)); } uint32_t @@ -221,26 +221,21 @@ SSL_SESSION_new(void) SSLerrorx(ERR_R_MALLOC_FAILURE); return (NULL); } - if ((ss->internal = calloc(1, sizeof(*ss->internal))) == NULL) { - free(ss); - SSLerrorx(ERR_R_MALLOC_FAILURE); - return (NULL); - } ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */ ss->references = 1; ss->timeout=60*5+4; /* 5 minute timeout by default */ ss->time = time(NULL); - ss->internal->prev = NULL; - ss->internal->next = NULL; + ss->prev = NULL; + ss->next = NULL; ss->tlsext_hostname = NULL; - ss->internal->tlsext_ecpointformatlist_length = 0; - ss->internal->tlsext_ecpointformatlist = NULL; - ss->internal->tlsext_supportedgroups_length = 0; - ss->internal->tlsext_supportedgroups = NULL; + ss->tlsext_ecpointformatlist_length = 0; + ss->tlsext_ecpointformatlist = NULL; + ss->tlsext_supportedgroups_length = 0; + ss->tlsext_supportedgroups = NULL; - CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->internal->ex_data); + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); return (ss); } @@ -738,7 +733,7 @@ remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); if (ret) { - r->internal->not_resumable = 1; + r->not_resumable = 1; if (ctx->internal->remove_session_cb != NULL) ctx->internal->remove_session_cb(ctx, r); SSL_SESSION_free(r); @@ -760,12 +755,12 @@ SSL_SESSION_free(SSL_SESSION *ss) if (i > 0) return; - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->internal->ex_data); + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); explicit_bzero(ss->master_key, sizeof ss->master_key); explicit_bzero(ss->session_id, sizeof ss->session_id); - ssl_sess_cert_free(ss->internal->sess_cert); + ssl_sess_cert_free(ss->sess_cert); X509_free(ss->peer); @@ -773,10 +768,9 @@ SSL_SESSION_free(SSL_SESSION *ss) free(ss->tlsext_hostname); free(ss->tlsext_tick); - free(ss->internal->tlsext_ecpointformatlist); - free(ss->internal->tlsext_supportedgroups); + free(ss->tlsext_ecpointformatlist); + free(ss->tlsext_supportedgroups); - freezero(ss->internal, sizeof(*ss->internal)); freezero(ss, sizeof(*ss)); } @@ -1007,7 +1001,7 @@ timeout_doall_arg(SSL_SESSION *s, TIMEOUT_PARAM *p) * save on locking overhead */ (void)lh_SSL_SESSION_delete(p->cache, s); SSL_SESSION_list_remove(p->ctx, s); - s->internal->not_resumable = 1; + s->not_resumable = 1; if (p->ctx->internal->remove_session_cb != NULL) p->ctx->internal->remove_session_cb(p->ctx, s); SSL_SESSION_free(s); @@ -1059,50 +1053,50 @@ ssl_clear_bad_session(SSL *s) static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s) { - if ((s->internal->next == NULL) || (s->internal->prev == NULL)) + if (s->next == NULL || s->prev == NULL) return; - if (s->internal->next == (SSL_SESSION *)&(ctx->internal->session_cache_tail)) { + if (s->next == (SSL_SESSION *)&(ctx->internal->session_cache_tail)) { /* last element in list */ - if (s->internal->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { + if (s->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { /* only one element in list */ ctx->internal->session_cache_head = NULL; ctx->internal->session_cache_tail = NULL; } else { - ctx->internal->session_cache_tail = s->internal->prev; - s->internal->prev->internal->next = + ctx->internal->session_cache_tail = s->prev; + s->prev->next = (SSL_SESSION *)&(ctx->internal->session_cache_tail); } } else { - if (s->internal->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { + if (s->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { /* first element in list */ - ctx->internal->session_cache_head = s->internal->next; - s->internal->next->internal->prev = + ctx->internal->session_cache_head = s->next; + s->next->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); } else { /* middle of list */ - s->internal->next->internal->prev = s->internal->prev; - s->internal->prev->internal->next = s->internal->next; + s->next->prev = s->prev; + s->prev->next = s->next; } } - s->internal->prev = s->internal->next = NULL; + s->prev = s->next = NULL; } static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s) { - if ((s->internal->next != NULL) && (s->internal->prev != NULL)) + if (s->next != NULL && s->prev != NULL) SSL_SESSION_list_remove(ctx, s); if (ctx->internal->session_cache_head == NULL) { ctx->internal->session_cache_head = s; ctx->internal->session_cache_tail = s; - s->internal->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); - s->internal->next = (SSL_SESSION *)&(ctx->internal->session_cache_tail); + s->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); + s->next = (SSL_SESSION *)&(ctx->internal->session_cache_tail); } else { - s->internal->next = ctx->internal->session_cache_head; - s->internal->next->internal->prev = s; - s->internal->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); + s->next = ctx->internal->session_cache_head; + s->next->prev = s; + s->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); ctx->internal->session_cache_head = s; } } -- cgit v1.2.3-55-g6feb