]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: peers: Wrong null "server_name" data field handling.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 13 Nov 2019 16:50:34 +0000 (17:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2019 13:48:33 +0000 (14:48 +0100)
As the peers protocol expects to parse at least one encoded integer value for
each stick-table data field even when not configured on the local side,
about the "server_name" data field we must emit something even if it has
not been set (no server was configured for instance).
As this data field is made of first one encoded integer which is the length
of the remaining data (the dictionary cache entry), we encode the length 0
when emitting such an absent dictionary cache entry.
On the remote side, when we decode such an integer with 0 as value, we stop
parsing the data field and that's it.

Must be backported to 2.0.

src/peers.c

index 473694501f086f9c4239c6ff77b3dffa2801438f..86ab96ede444b2e81a42ab0dc53d3f8079060616 100644 (file)
@@ -530,8 +530,11 @@ static int peer_prepare_updatemsg(char *msg, size_t size, struct peer_prep_param
                                        struct dcache *dc;
 
                                        de = stktable_data_cast(data_ptr, std_t_dict);
-                                       if (!de)
+                                       if (!de) {
+                                               /* No entry */
+                                               intencode(0, &cursor);
                                                break;
+                                       }
 
                                        dc = peer->dcache;
                                        cde.entry.key = de;
@@ -1446,6 +1449,10 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
                        struct dcache *dc;
                        char *end;
 
+                       if (!decoded_int) {
+                               /* No entry. */
+                               break;
+                       }
                        data_len = decoded_int;
                        if (*msg_cur + data_len > msg_end)
                                goto malformed_unlock;