When trying to read QMux transport parameters frame, the record length
is checked to ensure it is not bigger than the buffer size. The
objective is to detect as soon as possible when receiving data that
cannot be handled and to close the connection.
In fact, this check is not accurate, as it did not take into account the
size of the Record length field itself. This patch fixes the comparison
by substracting with the size of the decoded varint.
No need to backport.
struct buffer *buf = &ctx->rxbuf;
const unsigned char *pos, *old, *end;
uint64_t rlen;
- size_t ret;
+ size_t ret, rlen_sz = 0;
if (!conn_ctrl_ready(conn))
goto fail;
/* Read record length. */
if (!ctx->rxrlen) {
- if (!b_quic_dec_int(&rlen, buf, NULL))
+ if (!b_quic_dec_int(&rlen, buf, &rlen_sz))
goto not_ready;
/* Reject too small or too big records. */
- if (!rlen || rlen > b_size(buf))
+ if (!rlen || rlen > b_size(buf) - rlen_sz)
goto fail;
ctx->rxrlen = rlen;