]> git.kaiwu.me - nginx.git/commitdiff
QUIC: update packet length for short packets too.
authorSergey Kandaurov <pluknet@nginx.com>
Tue, 8 Sep 2020 10:27:39 +0000 (13:27 +0300)
committerSergey Kandaurov <pluknet@nginx.com>
Tue, 8 Sep 2020 10:27:39 +0000 (13:27 +0300)
During long packet header parsing, pkt->len is updated with the Length
field value that is used to find next coalesced packets in a datagram.
For short packets it still contained the whole QUIC packet size.

This change uniforms packet length handling to always contain the total
length of the packet number and protected packet payload in pkt->len.

src/event/ngx_event_quic_protection.c
src/event/ngx_event_quic_transport.c

index fd11e591e2b7e71cb4ac10a1a0551986e1ed1648..261f02d7f9be2d5322ad7b270cbed2715cd115e8 100644 (file)
@@ -1058,13 +1058,12 @@ ngx_quic_decrypt(ngx_quic_header_t *pkt, ngx_ssl_conn_t *ssl_conn,
     /* packet protection */
 
     in.data = p;
+    in.len = pkt->len - pnl;
 
     if (ngx_quic_long_pkt(pkt->flags)) {
-        in.len = pkt->len - pnl;
         badflags = clearflags & NGX_QUIC_PKT_LONG_RESERVED_BIT;
 
     } else {
-        in.len = pkt->data + pkt->len - p;
         badflags = clearflags & NGX_QUIC_PKT_SHORT_RESERVED_BIT;
     }
 
index 36e987f92a0a38f2851eb6c0816b0629c7c38ad4..1d270a2f2703da462782b54bc0069003d5f79ad2 100644 (file)
@@ -511,6 +511,7 @@ ngx_quic_parse_short_header(ngx_quic_header_t *pkt, ngx_str_t *dcid)
     }
 
     pkt->raw->pos = p;
+    pkt->len = end - p;
 
     return NGX_OK;
 }