From 0f725acb953e373ddb149758399eb50d0bffe528 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 29 Aug 2025 14:17:44 +0200 Subject: [PATCH] BUG/MINOR: quic: fix room check if padding requested qc_prep_pkts() activates padding when building an Initial packet. This ensures that resulting datagram will always be at least 1.200 bytes, which is mandatory to prevent deadlock over anti-amplication. Prior to padding activation, a check is performed to ensure that output buffer is big enough for a padded datagram. However, this did not take into account previously built packets which would be coalesced in the same datagram. Thus this patch fixes this comparison check. In theory, prior to this patch, in some cases Initial packets could not be built despite a datagram of the proper size. Currently, this probably never happens as Initial packet is always the first encoded in a datagram, thus there is no coalesced packet prior to it. However, there is no hard requirement on this, so it's better to reflect this in the code. This should be backported up to 2.6. (cherry picked from commit 34d5bfd23c30e08228d7939ba94a839b03716489) Signed-off-by: Christopher Faulet (cherry picked from commit 0ecea5e96a3322c74b8eb2478f45d286bf43a6f9) Signed-off-by: Christopher Faulet (cherry picked from commit ffe81c3628e64800156d276c6716077d18f327e4) Signed-off-by: Christopher Faulet --- src/quic_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic_tx.c b/src/quic_tx.c index b347b4b..2e87168 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -587,7 +587,7 @@ static int qc_prep_pkts(struct quic_conn *qc, struct buffer *buf, */ if (qel == qc->iel && (!LIST_ISEMPTY(frms) || probe)) { /* Ensure that no ack-eliciting packets are sent into too small datagrams */ - if (end - pos < QUIC_INITIAL_PACKET_MINLEN) { + if (end - pos + dglen < QUIC_INITIAL_PACKET_MINLEN) { TRACE_PROTO("No more enough room to build an Initial packet", QUIC_EV_CONN_PHPKTS, qc); break; -- 1.7.10.4