# HG changeset patch # User Vladimir Homutov # Date 1625480230 -10800 # Node ID 5b0c229ba5fe41a2a24c592da09310b0ffa8500a # Parent 0ac25efb2da30153ce1993fd9e81be14ba1525f3 QUIC: fixed padding calculation. Sometimes, QUIC packets need to be of certain (or minimal) size. This is achieved by adding PADDING frames. It is possible, that adding padding will affect header size, thus forcing us to recalculate padding size once more. diff --git a/src/event/quic/ngx_event_quic_output.c b/src/event/quic/ngx_event_quic_output.c --- a/src/event/quic/ngx_event_quic_output.c +++ b/src/event/quic/ngx_event_quic_output.c @@ -368,6 +368,9 @@ ngx_quic_output_packet(ngx_connection_t } if (out.len < pad_len) { + /* compensate for potentially enlarged header in Length bytes */ + pad_len -= ngx_quic_create_header(&pkt, NULL, pad_len, NULL) + - ngx_quic_create_header(&pkt, NULL, out.len, NULL); ngx_memset(p, NGX_QUIC_FT_PADDING, pad_len - out.len); out.len = pad_len; }