]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse-ssl: avoid a possible crash on OOM in ssl_bind_parse_npn()
authorWilly Tarreau <w@1wt.eu>
Thu, 29 Dec 2022 10:11:02 +0000 (11:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 2 Jan 2023 08:51:35 +0000 (09:51 +0100)
Upon out of memory condition at boot, we could possibly crash when
parsing the "npn" bind line keyword since it's used unchecked. There's
no real need to backport this though it will not hurt.

src/cfgparse-ssl.c

index 4f999e1066decd9c80a4b1c7b31e76d2fedd9090..75af0e838bd0db06146e87584578e527c462fe24 100644 (file)
@@ -1016,6 +1016,11 @@ static int ssl_bind_parse_npn(char **args, int cur_arg, struct proxy *px, struct
         */
        conf->npn_len = strlen(args[cur_arg + 1]) + 1;
        conf->npn_str = calloc(1, conf->npn_len + 1);
+       if (!conf->npn_str) {
+               memprintf(err, "out of memory");
+               return ERR_ALERT | ERR_FATAL;
+       }
+
        memcpy(conf->npn_str + 1, args[cur_arg + 1], conf->npn_len);
 
        /* replace commas with the name length */