]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: Check malloc return code
authorThierry FOURNIER / OZON.IO <thierry.fournier@ozon.io>
Thu, 6 Oct 2016 08:35:29 +0000 (10:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 24 Oct 2016 17:13:12 +0000 (19:13 +0200)
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.

src/ssl_sock.c

index 4b1e8856f2a535fb20c962aea44b694ceaf10588..8a0961a5f4da1fc45f4bced0710652594421c333 100644 (file)
@@ -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;