Commit
b224f63c1 ("BUG/MEDIUM: stick-table: restrict key sizes to what
fits in a buffer") trims string keys in stksess_setkey() so that the
update message fits in a buffer, but string keys received from a peer
are copied directly and only bounded by the table's key size. A peer
with a larger bufsize, or a forged message, can thus store a key which
cannot be encoded when it is later taught to another peer. Since commit
ef4405d67 ("BUG/MEDIUM: peers: bound stick-table update messages") this
does not overflow the trash buffer anymore, but the peer session is
closed and reopened in loop and the resync never completes, as reported
in GitHub issue #3576.
Let's apply the same trimming on the receive path. This must be
backported wherever
b224f63c1 was.
}
to_store = MIN(to_read, table->key_size - 1);
+ if (to_store + table->proto_size > global.tune.bufsize)
+ to_store = global.tune.bufsize - table->proto_size;
if (*msg_cur + to_store > msg_end) {
TRACE_ERROR("malformed update message: invalid string (too big)", PEERS_EV_SESS_IO|PEERS_EV_RX_MSG|PEERS_EV_PROTO_ERR, appctx, p, st);
goto malformed_free_newts;