]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
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)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Feb 2022 15:40:04 +0000 (16:40 +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.

src/proxy.c

index c486376a5d463fa4531bf3b80a90e09ecb035f46..4991d9457ab2bd8cb79e896814ea84d0c3e247c8 100644 (file)
@@ -1839,7 +1839,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);