mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
HTTP/2: validate client request scheme.
The scheme is validated as per RFC 3986, Section 3.1.
This commit is contained in:
parent
c804eb7748
commit
94a2ce426f
@ -3474,6 +3474,9 @@ ngx_http_v2_parse_method(ngx_http_request_t *r, ngx_str_t *value)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
|
ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
|
||||||
{
|
{
|
||||||
|
u_char c, ch;
|
||||||
|
ngx_uint_t i;
|
||||||
|
|
||||||
if (r->schema_start) {
|
if (r->schema_start) {
|
||||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||||
"client sent duplicate :scheme header");
|
"client sent duplicate :scheme header");
|
||||||
@ -3488,6 +3491,26 @@ ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
|
|||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < value->len; i++) {
|
||||||
|
ch = value->data[i];
|
||||||
|
|
||||||
|
c = (u_char) (ch | 0x20);
|
||||||
|
if (c >= 'a' && c <= 'z') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')
|
||||||
|
&& i > 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||||
|
"client sent invalid :scheme header: \"%V\"", value);
|
||||||
|
|
||||||
|
return NGX_DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
r->schema_start = value->data;
|
r->schema_start = value->data;
|
||||||
r->schema_end = value->data + value->len;
|
r->schema_end = value->data + value->len;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user