Remove some code for a contributor that we cannot find
[openssl.git] / ssl / ssl_lib.c
index 062f5cef3f634f9fe1d9232e24bbe7e70377f040..b678fcfbbb3d6b17d8f1088a0e97435f93781c9a 100644 (file)
@@ -1125,9 +1125,6 @@ void SSL_free(SSL *s)
 {
     int i;
 
-    if (s == NULL)
-        return;
-
     CRYPTO_DOWN_REF(&s->references, &i, s->lock);
     REF_PRINT_COUNT("SSL", s);
     if (i > 0)
@@ -3427,6 +3424,18 @@ void ssl_update_cache(SSL *s, int mode)
     if (s->session->session_id_length == 0)
         return;
 
+    /*
+     * If sid_ctx_length is 0 there is no specific application context
+     * associated with this session, so when we try to resume it and
+     * SSL_VERIFY_PEER is requested, we have no indication that this is
+     * actually a session for the proper application context, and the
+     * *handshake* will fail, not just the resumption attempt.
+     * Do not cache these sessions that are not resumable.
+     */
+    if (s->session->sid_ctx_length == 0
+            && (s->verify_mode & SSL_VERIFY_PEER) != 0)
+        return;
+
     i = s->session_ctx->session_cache_mode;
     if ((i & mode) != 0
         && (!s->hit || SSL_IS_TLS13(s))