From 1ac31c01b4a2df79a512a7b6bde67002b3e5259e Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Sat, 14 Mar 2020 03:15:09 +0300 Subject: [PATCH] Fixed header protection application with pn length > 1. --- src/event/ngx_event_quic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c index 7819e3f51..199284162 100644 --- a/src/event/ngx_event_quic.c +++ b/src/event/ngx_event_quic.c @@ -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;