summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2020-05-07 12:34:04 +0300
committerVladimir Homutov <vl@nginx.com>2020-05-07 12:34:04 +0300
commit1816f3af588f4809c2bf3bd7045e12156eaa8275 (patch)
tree066d7091fe5d6e63af70189c2145cc1bf1b20cca /src
parent9ed0d4c9aed944d6eac72e3f5c98d73ce48e522d (diff)
downloadnginx-1816f3af588f4809c2bf3bd7045e12156eaa8275.tar.gz
nginx-1816f3af588f4809c2bf3bd7045e12156eaa8275.tar.bz2
Cleaned up firefox workaround.
The idea is to skip any zeroes that follow valid QUIC packet. Currently such behavior can be only observed with Firefox which sends zero-padded initial packets.
Diffstat (limited to 'src')
-rw-r--r--src/event/ngx_event_quic.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c
index ed6c6cd4e..f270ab7fe 100644
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -163,6 +163,7 @@ static ngx_int_t ngx_quic_close_streams(ngx_connection_t *c,
ngx_quic_connection_t *qc);
static ngx_int_t ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b);
+static ngx_inline u_char *ngx_quic_skip_zero_padding(ngx_buf_t *b);
static ngx_int_t ngx_quic_initial_input(ngx_connection_t *c,
ngx_quic_header_t *pkt);
static ngx_int_t ngx_quic_handshake_input(ngx_connection_t *c,
@@ -664,6 +665,8 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_ssl_t *ssl, ngx_quic_tp_t *tp,
/* pos is at header end, adjust by actual packet length */
pkt->raw->pos += pkt->len;
+ (void) ngx_quic_skip_zero_padding(pkt->raw);
+
return ngx_quic_input(c, pkt->raw);
}
@@ -1057,14 +1060,6 @@ ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b)
pkt.log = c->log;
pkt.flags = p[0];
- if (pkt.flags == 0) {
- /* XXX: no idea WTF is this, just ignore */
- ngx_log_error(NGX_LOG_ALERT, c->log, 0,
- "quic packet with zero flags, presumably"
- " firefox padding, ignored");
- break;
- }
-
/* TODO: check current state */
if (ngx_quic_long_pkt(pkt.flags)) {
@@ -1108,14 +1103,26 @@ ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b)
*/
/* b->pos is at header end, adjust by actual packet length */
- p = b->pos + pkt.len;
- b->pos = p; /* reset b->pos to the next packet start */
+ b->pos += pkt.len;
+ p = ngx_quic_skip_zero_padding(b);
}
return NGX_OK;
}
+/* firefox workaround: skip zero padding at the end of quic packet */
+static ngx_inline u_char *
+ngx_quic_skip_zero_padding(ngx_buf_t *b)
+{
+ while (b->pos < b->last && *(b->pos) == 0) {
+ b->pos++;
+ }
+
+ return b->pos;
+}
+
+
static ngx_int_t
ngx_quic_initial_input(ngx_connection_t *c, ngx_quic_header_t *pkt)
{