From: Thierry FOURNIER / OZON.IO Date: Thu, 6 Oct 2016 08:35:29 +0000 (+0200) Subject: BUG/MINOR: ssl: Check malloc return code X-Git-Tag: v1.7-dev5~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7a3bd3b9dc43509bb1869389dcf91e35c0155f9b;p=thirdparty%2Fhaproxy.git BUG/MINOR: ssl: Check malloc return code If malloc() can't allocate memory and return NULL, a segfaut will raises. This patch should be backported in the 1.6 and 1.5 version. --- diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 4b1e8856f2..8a0961a5f4 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -1704,6 +1704,8 @@ static int ssl_sock_add_cert_sni(SSL_CTX *ctx, struct bind_conf *s, char *name, int j, len; len = strlen(name); sc = malloc(sizeof(struct sni_ctx) + len + 1); + if (!sc) + return order; for (j = 0; j < len; j++) sc->name.key[j] = tolower(name[j]); sc->name.key[len] = 0;