]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: Init params before parsing a new server-state line
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Feb 2021 15:47:11 +0000 (16:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Feb 2021 17:03:59 +0000 (18:03 +0100)
Same static arrays of parameters are used to parse all server-state
lines. Thus it is important to reinit them to be sure to not get params from
the previous line, eventually from the previous loaded file.

This patch should be backported to all stable branches. However, in 2.0 and
prior, the parsing of server-state lines are inlined in apply_server_state()
function. Thus the patch will have to be adapted on these versions.

src/server.c

index 1191eecd5f86e0d37031c713abeaeb3568446bbd..21ad43833e1b4a80c20c200d00d522d869c9e8aa 100644 (file)
@@ -3110,6 +3110,8 @@ static void srv_state_parse_line(char *buf, const int version, char **params, ch
        buf[buflen - 1] = '\0';
 
        /* we're now ready to move the line into *srv_params[] */
+       memset(params, 0, SRV_STATE_FILE_MAX_FIELDS * sizeof(*params));
+       memset(srv_params, 0, SRV_STATE_FILE_MAX_FIELDS * sizeof(*srv_params));
        params[0] = cur;
        arg = 1;
        srv_arg = 0;