86412d1179434e1537a3ec9517ce9b0a6ded9f43
[feed/packages.git] / net / haproxy / patches / 0013-BUG-MEDIUM-ssl-avoid-double-free-when-releasing-bind.patch
1 From 8e24409513ae20000256b0dc649cb83412ffb20e Mon Sep 17 00:00:00 2001
2 From: Willy Tarreau <w@1wt.eu>
3 Date: Thu, 22 Dec 2016 17:57:46 +0100
4 Subject: [PATCH 13/19] BUG/MEDIUM: ssl: avoid double free when releasing
5 bind_confs
6
7 ssl_sock functions don't mark pointers as NULL after freeing them. So
8 if a "bind" line specifies some SSL settings without the "ssl" keyword,
9 they will get freed at the end of check_config_validity(), then freed
10 a second time on exit. Simply mark the pointers as NULL to fix this.
11 This fix needs to be backported to 1.7 and 1.6.
12 (cherry picked from commit 94ff03af84ee0c4a2b6cfb92332fcafbcdc48765)
13 ---
14 src/cfgparse.c | 7 +++++++
15 src/ssl_sock.c | 2 ++
16 2 files changed, 9 insertions(+)
17
18 diff --git a/src/cfgparse.c b/src/cfgparse.c
19 index ec8f6a1..63716fa 100644
20 --- a/src/cfgparse.c
21 +++ b/src/cfgparse.c
22 @@ -9050,6 +9050,13 @@ out_uri_auth_compat:
23 LIST_DEL(&bind_conf->keys_ref->list);
24 free(bind_conf->keys_ref);
25 }
26 + bind_conf->keys_ref = NULL;
27 + bind_conf->crl_file = NULL;
28 + bind_conf->ecdhe = NULL;
29 + bind_conf->ciphers = NULL;
30 + bind_conf->ca_sign_pass = NULL;
31 + bind_conf->ca_sign_file = NULL;
32 + bind_conf->ca_file = NULL;
33 #endif /* USE_OPENSSL */
34 }
35
36 diff --git a/src/ssl_sock.c b/src/ssl_sock.c
37 index 322488e..55eaa28 100644
38 --- a/src/ssl_sock.c
39 +++ b/src/ssl_sock.c
40 @@ -3334,6 +3334,8 @@ ssl_sock_free_ca(struct bind_conf *bind_conf)
41 EVP_PKEY_free(bind_conf->ca_sign_pkey);
42 if (bind_conf->ca_sign_cert)
43 X509_free(bind_conf->ca_sign_cert);
44 + bind_conf->ca_sign_pkey = NULL;
45 + bind_conf->ca_sign_cert = NULL;
46 }
47
48 /*
49 --
50 2.10.2
51