comparison src/http/v2/ngx_http_v2.c @ 6988:cc823122d50d

HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR. It's required by RFC 7540. While there is no real harm from such frames, that should help to detect broken clients. Based on a patch by Piotr Sikora.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 24 Apr 2017 14:16:57 +0300
parents 28dc369899ea
children 2c4dbcd6f2e4
comparison
equal deleted inserted replaced
6987:5116cfea1e9a 6988:cc823122d50d
2164 2164
2165 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 2165 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
2166 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", 2166 "http2 WINDOW_UPDATE frame sid:%ui window:%uz",
2167 h2c->state.sid, window); 2167 h2c->state.sid, window);
2168 2168
2169 if (window == 0) {
2170 if (h2c->state.sid == 0) {
2171 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
2172 "client sent WINDOW_UPDATE frame "
2173 "with incorrect window increment 0");
2174
2175 return ngx_http_v2_connection_error(h2c,
2176 NGX_HTTP_V2_PROTOCOL_ERROR);
2177 }
2178
2179 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
2180 "client sent WINDOW_UPDATE frame for stream %ui "
2181 "with incorrect window increment 0", h2c->state.sid);
2182
2183 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
2184
2185 if (node && node->stream) {
2186 if (ngx_http_v2_terminate_stream(h2c, node->stream,
2187 NGX_HTTP_V2_PROTOCOL_ERROR)
2188 == NGX_ERROR)
2189 {
2190 return ngx_http_v2_connection_error(h2c,
2191 NGX_HTTP_V2_INTERNAL_ERROR);
2192 }
2193
2194 } else {
2195 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid,
2196 NGX_HTTP_V2_PROTOCOL_ERROR)
2197 == NGX_ERROR)
2198 {
2199 return ngx_http_v2_connection_error(h2c,
2200 NGX_HTTP_V2_INTERNAL_ERROR);
2201 }
2202 }
2203
2204 return ngx_http_v2_state_complete(h2c, pos, end);
2205 }
2206
2169 if (h2c->state.sid) { 2207 if (h2c->state.sid) {
2170 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); 2208 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
2171 2209
2172 if (node == NULL || node->stream == NULL) { 2210 if (node == NULL || node->stream == NULL) {
2173 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 2211 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,