Make sure we save ALPN data in the session
authorMatt Caswell <matt@openssl.org>
Mon, 31 Jul 2017 10:42:48 +0000 (11:42 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 31 Aug 2017 14:03:35 +0000 (15:03 +0100)
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/3926)

ssl/statem/extensions_clnt.c

index 3a198f4..329a800 100644 (file)
@@ -1400,6 +1400,17 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
     }
     s->s3->alpn_selected_len = len;
 
     }
     s->s3->alpn_selected_len = len;
 
+    /* We also put a copy in the session */
+    OPENSSL_free(s->session->ext.alpn_selected);
+    s->session->ext.alpn_selected = OPENSSL_memdup(s->s3->alpn_selected,
+                                                   s->s3->alpn_selected_len);
+    s->session->ext.alpn_selected_len = s->s3->alpn_selected_len;
+
+    if (s->session->ext.alpn_selected == NULL) {
+        *al = SSL_AD_INTERNAL_ERROR;
+        return 0;
+    }
+
     return 1;
 }
 
     return 1;
 }