Mercurial > hg > nginx
comparison src/http/v2/ngx_http_v2.c @ 7565:fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Don't waste server resources by sending RST_STREAM frames. Instead,
reject WINDOW_UPDATE frames with invalid zero increment by closing
connection with PROTOCOL_ERROR.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 10 Sep 2019 15:33:38 +0300 |
parents | 29b2dc731503 |
children | 2e61e4b6bcd9 |
comparison
equal
deleted
inserted
replaced
7564:29b2dc731503 | 7565:fd6dcc6f8a49 |
---|---|
2229 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | 2229 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
2230 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", | 2230 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", |
2231 h2c->state.sid, window); | 2231 h2c->state.sid, window); |
2232 | 2232 |
2233 if (window == 0) { | 2233 if (window == 0) { |
2234 if (h2c->state.sid == 0) { | |
2235 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
2236 "client sent WINDOW_UPDATE frame " | |
2237 "with incorrect window increment 0"); | |
2238 | |
2239 return ngx_http_v2_connection_error(h2c, | |
2240 NGX_HTTP_V2_PROTOCOL_ERROR); | |
2241 } | |
2242 | |
2243 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | 2234 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
2244 "client sent WINDOW_UPDATE frame for stream %ui " | 2235 "client sent WINDOW_UPDATE frame " |
2245 "with incorrect window increment 0", h2c->state.sid); | 2236 "with incorrect window increment 0"); |
2246 | 2237 |
2247 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); | 2238 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
2248 | |
2249 if (node && node->stream) { | |
2250 if (ngx_http_v2_terminate_stream(h2c, node->stream, | |
2251 NGX_HTTP_V2_PROTOCOL_ERROR) | |
2252 == NGX_ERROR) | |
2253 { | |
2254 return ngx_http_v2_connection_error(h2c, | |
2255 NGX_HTTP_V2_INTERNAL_ERROR); | |
2256 } | |
2257 | |
2258 } else { | |
2259 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, | |
2260 NGX_HTTP_V2_PROTOCOL_ERROR) | |
2261 == NGX_ERROR) | |
2262 { | |
2263 return ngx_http_v2_connection_error(h2c, | |
2264 NGX_HTTP_V2_INTERNAL_ERROR); | |
2265 } | |
2266 } | |
2267 | |
2268 return ngx_http_v2_state_complete(h2c, pos, end); | |
2269 } | 2239 } |
2270 | 2240 |
2271 if (h2c->state.sid) { | 2241 if (h2c->state.sid) { |
2272 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); | 2242 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); |
2273 | 2243 |