From: Frédéric Lécaille Date: Wed, 13 Nov 2019 16:50:34 +0000 (+0100) Subject: BUG/MINOR: peers: Wrong null "server_name" data field handling. X-Git-Tag: v2.1.0~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af9990f0358eb61dbec14c171ae26829932ddf19;p=thirdparty%2Fhaproxy.git BUG/MINOR: peers: Wrong null "server_name" data field handling. 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. --- diff --git a/src/peers.c b/src/peers.c index 473694501f..86ab96ede4 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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;