From: Amaury Denoyelle Date: Tue, 12 Aug 2025 08:39:48 +0000 (+0200) Subject: MEDIUM: quic: ensure empty packets are never built X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2F20250812-ade-quic-fix-padding;p=thirdparty%2Fhaproxy.git MEDIUM: quic: ensure empty packets are never built Previously, qc_do_build_pkt() had a special case when an empty packet was generated. In this case, a PADDING frame was inserted. This specific block was removed as padding support was centralized by the previous patch. However, such empty packets have no real purpose, and also are non efficient. Add a BUG_ON() to ensure that caller never invoke qc_do_build_pkt() if there is no data to emit. qc_do_build_pkt() is a tedious function which already had some issues. As such, this change is labelled as MEDIUM, as it is not 100% sure that empty packet case is never encountered during emission. --- diff --git a/src/quic_tx.c b/src/quic_tx.c index bfae52cd2..5452469ef 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -1937,6 +1937,9 @@ static int qc_do_build_pkt(unsigned char *pos, const unsigned char *end, dglen += 1; } + /* Caller must not try to build an empty packet. */ + BUG_ON(LIST_ISEMPTY(&frm_list) && !add_ping_frm && !ack_frm_len && !cc); + /* Handle Initial packet padding if necessary. */ if (padding && dglen < QUIC_INITIAL_PACKET_MINLEN) { padding_len = QUIC_INITIAL_PACKET_MINLEN - dglen;