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.
This commit is contained in:
Frdric Lcaille 2019-11-13 17:50:34 +01:00 committed by Willy Tarreau
parent ec1c10b839
commit af9990f035

View 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;