X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=ssl%2Fssl_sess.c;h=41abe44a82bbd328b937c55dd2150468f02668ec;hp=f13e466d2c0fedd0e255b965f005049e27c69fd9;hb=a8c1c7040aabdb78f9bec21ba16be8f262de1444;hpb=80c630f6574a33b1c633815a174110d10ec37c60 diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index f13e466d2c..41abe44a82 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -359,6 +359,7 @@ int ssl_get_new_session(SSL *s, int session) CRYPTO_THREAD_unlock(s->session_ctx->lock); CRYPTO_THREAD_unlock(s->lock); /* Choose a session ID */ + memset(ss->session_id, 0, ss->session_id_length); tmp = ss->session_id_length; if (!cb(s, ss->session_id, &tmp)) { /* The callback failed */ @@ -471,6 +472,7 @@ int ssl_get_prev_session(SSL *s, const PACKET *ext, const PACKET *session_id) SSL_SESSION data; size_t local_len; data.ssl_version = s->version; + memset(data.session_id, 0, sizeof(data.session_id)); if (!PACKET_copy_all(session_id, data.session_id, sizeof(data.session_id), &local_len)) { @@ -774,28 +776,20 @@ int SSL_SESSION_up_ref(SSL_SESSION *ss) int SSL_set_session(SSL *s, SSL_SESSION *session) { - int ret = 0; - if (session != NULL) { - if (s->ctx->method != s->method) { - if (!SSL_set_ssl_method(s, s->ctx->method)) - return (0); - } + ssl_clear_bad_session(s); + if (s->ctx->method != s->method) { + if (!SSL_set_ssl_method(s, s->ctx->method)) + return 0; + } + if (session != NULL) { SSL_SESSION_up_ref(session); - SSL_SESSION_free(s->session); - s->session = session; - s->verify_result = s->session->verify_result; - ret = 1; - } else { - SSL_SESSION_free(s->session); - s->session = NULL; - if (s->ctx->method != s->method) { - if (!SSL_set_ssl_method(s, s->ctx->method)) - return (0); - } - ret = 1; + s->verify_result = session->verify_result; } - return (ret); + SSL_SESSION_free(s->session); + s->session = session; + + return 1; } long SSL_SESSION_set_timeout(SSL_SESSION *s, long t) @@ -994,7 +988,7 @@ int ssl_clear_bad_session(SSL *s) if ((s->session != NULL) && !(s->shutdown & SSL_SENT_SHUTDOWN) && !(SSL_in_init(s) || SSL_in_before(s))) { - SSL_CTX_remove_session(s->ctx, s->session); + SSL_CTX_remove_session(s->session_ctx, s->session); return (1); } else return (0);