]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: ssl: properly reset the reused_sess during a forced handshake
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2016 20:54:21 +0000 (21:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2016 20:54:21 +0000 (21:54 +0100)
We have a bug when SSL reuse is disabled on the server side : we reset
the context but do not set it to NULL, causing a multiple free of the
same entry. It seems like this bug cannot appear as-is with the current
code (or the conditions to get it are not obvious) but it did definitely
strike when trying to fix another bug with the SNI which forced a new
handshake.

This fix should be backported to 1.7, 1.6 and 1.5.

src/ssl_sock.c

index 06d7cabf899356e8d853a5a71dba5ee278df21b5..b681d639e198e5c46e2e97ca8466d60dedfb2fa1 100644 (file)
@@ -3654,8 +3654,10 @@ reneg_ok:
                                global.ssl_be_keys_max = global.ssl_be_keys_per_sec.curr_ctr;
 
                        /* check if session was reused, if not store current session on server for reuse */
-                       if (objt_server(conn->target)->ssl_ctx.reused_sess)
+                       if (objt_server(conn->target)->ssl_ctx.reused_sess) {
                                SSL_SESSION_free(objt_server(conn->target)->ssl_ctx.reused_sess);
+                               objt_server(conn->target)->ssl_ctx.reused_sess = NULL;
+                       }
 
                        if (!(objt_server(conn->target)->ssl_ctx.options & SRV_SSL_O_NO_REUSE))
                                objt_server(conn->target)->ssl_ctx.reused_sess = SSL_get1_session(conn->xprt_ctx);