Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_parse.c @ 8550:234e9d89ff7f quic
HTTP/3: reject HTTP/2 frames.
As per HTTP/3 draft 30, section 7.2.8:
Frame types that were used in HTTP/2 where there is no corresponding
HTTP/3 frame have also been reserved (Section 11.2.1). These frame
types MUST NOT be sent, and their receipt MUST be treated as a
connection error of type H3_FRAME_UNEXPECTED.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 16 Sep 2020 12:27:23 +0100 |
parents | d70a38acaea0 |
children | 351d62300832 |
comparison
equal
deleted
inserted
replaced
8549:d70a38acaea0 | 8550:234e9d89ff7f |
---|---|
6 | 6 |
7 | 7 |
8 #include <ngx_config.h> | 8 #include <ngx_config.h> |
9 #include <ngx_core.h> | 9 #include <ngx_core.h> |
10 #include <ngx_http.h> | 10 #include <ngx_http.h> |
11 | |
12 | |
13 #define ngx_http_v3_is_v2_frame(type) \ | |
14 ((type) == 0x02 || (type) == 0x06 || (type) == 0x08 || (type) == 0x09) | |
11 | 15 |
12 | 16 |
13 static ngx_int_t ngx_http_v3_parse_lookup(ngx_connection_t *c, | 17 static ngx_int_t ngx_http_v3_parse_lookup(ngx_connection_t *c, |
14 ngx_uint_t dynamic, ngx_uint_t index, ngx_str_t *name, ngx_str_t *value); | 18 ngx_uint_t dynamic, ngx_uint_t index, ngx_str_t *name, ngx_str_t *value); |
15 | 19 |
180 if (rc != NGX_DONE) { | 184 if (rc != NGX_DONE) { |
181 return rc; | 185 return rc; |
182 } | 186 } |
183 | 187 |
184 st->type = st->vlint.value; | 188 st->type = st->vlint.value; |
189 | |
190 if (ngx_http_v3_is_v2_frame(st->type)) { | |
191 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; | |
192 } | |
193 | |
185 st->state = sw_length; | 194 st->state = sw_length; |
186 break; | 195 break; |
187 | 196 |
188 case sw_length: | 197 case sw_length: |
189 | 198 |
984 st->type = st->vlint.value; | 993 st->type = st->vlint.value; |
985 | 994 |
986 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 995 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
987 "http3 parse frame type:%ui", st->type); | 996 "http3 parse frame type:%ui", st->type); |
988 | 997 |
998 if (ngx_http_v3_is_v2_frame(st->type)) { | |
999 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; | |
1000 } | |
1001 | |
989 if (st->state == sw_first_type | 1002 if (st->state == sw_first_type |
990 && st->type != NGX_HTTP_V3_FRAME_SETTINGS) | 1003 && st->type != NGX_HTTP_V3_FRAME_SETTINGS) |
991 { | 1004 { |
992 return NGX_HTTP_V3_ERR_MISSING_SETTINGS; | 1005 return NGX_HTTP_V3_ERR_MISSING_SETTINGS; |
993 } | 1006 } |
1579 if (st->type == NGX_HTTP_V3_FRAME_HEADERS) { | 1592 if (st->type == NGX_HTTP_V3_FRAME_HEADERS) { |
1580 /* trailers */ | 1593 /* trailers */ |
1581 goto done; | 1594 goto done; |
1582 } | 1595 } |
1583 | 1596 |
1597 if (ngx_http_v3_is_v2_frame(st->type)) { | |
1598 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; | |
1599 } | |
1600 | |
1584 st->state = sw_length; | 1601 st->state = sw_length; |
1585 break; | 1602 break; |
1586 | 1603 |
1587 case sw_length: | 1604 case sw_length: |
1588 | 1605 |