]> git.kaiwu.me - nginx.git/commitdiff
Fixed header protection application with pn length > 1.
authorSergey Kandaurov <pluknet@nginx.com>
Sat, 14 Mar 2020 00:15:09 +0000 (03:15 +0300)
committerSergey Kandaurov <pluknet@nginx.com>
Sat, 14 Mar 2020 00:15:09 +0000 (03:15 +0300)
src/event/ngx_event_quic.c

index 7819e3f51debd9a53d7dc9bff98ef9515cefddb4..199284162c4d9c4868fcef1f4cc7c518092633c7 100644 (file)
@@ -1637,7 +1637,10 @@ ngx_quic_decrypt(ngx_connection_t *c, ngx_quic_header_t *pkt)
 
     ngx_memcpy(ad.data, pkt->data, ad.len);
     ad.data[0] = clearflags;
-    ad.data[ad.len - pnl] = (u_char) pn;
+
+    do {
+        ad.data[ad.len - pnl] = pn >> (8 * (pnl - 1)) % 256;
+    } while (--pnl);
 
     nonce = ngx_pstrdup(c->pool, &pkt->secret->iv);
     nonce[11] ^= pn;