BUG/MINOR: proxy: preset the error message pointer to NULL in parse_new_proxy()
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Feb 2022 15:37:19 +0000 (16:37 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 25 Feb 2022 12:20:53 +0000 (13:20 +0100)
As reported by Coverity in issue #1568, a missing initialization of the
error message pointer in parse_new_proxy() may result in displaying garbage
or crashing in case of memory allocation error when trying to create a new
proxy on startup.

This should be backported to 2.4.

(cherry picked from commit 282b6a7539add7517f2b16cc82b6a3509492fd76)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/proxy.c

index e583e51..c671831 100644 (file)
@@ -1838,7 +1838,7 @@ struct proxy *parse_new_proxy(const char *name, unsigned int cap,
                               const struct proxy *defproxy)
 {
        struct proxy *curproxy = NULL;
-       char *errmsg;
+       char *errmsg = NULL;
 
        if (!(curproxy = alloc_new_proxy(name, cap, &errmsg))) {
                ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg);