aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2014-04-21 18:59:53 +0400
committerValentin Bartenev <vbart@nginx.com>2014-04-21 18:59:53 +0400
commita57959b6cdc3729bc8e5bc380c6f47399720da6f (patch)
tree6a9a170fcb6f5375c65f02ed7529010300f20bf1 /src
parent7d53ec166a4f99cdc05ac32d5d20c82388f9ee86 (diff)
downloadnginx-a57959b6cdc3729bc8e5bc380c6f47399720da6f.tar.gz
nginx-a57959b6cdc3729bc8e5bc380c6f47399720da6f.zip
SPDY: Stream-ID restrictions according to specification.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_spdy.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/http/ngx_http_spdy.c b/src/http/ngx_http_spdy.c
index 9bd624c82..9d6b67f80 100644
--- a/src/http/ngx_http_spdy.c
+++ b/src/http/ngx_http_spdy.c
@@ -937,6 +937,27 @@ ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, u_char *pos,
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0,
"spdy SYN_STREAM frame sid:%ui prio:%ui", sid, prio);
+ if (sid % 2 == 0 || sid <= sc->last_sid) {
+ ngx_log_error(NGX_LOG_INFO, sc->connection->log, 0,
+ "client sent SYN_STREAM frame "
+ "with invalid Stream-ID %ui", sid);
+
+ stream = ngx_http_spdy_get_stream_by_id(sc, sid);
+
+ if (stream) {
+ if (ngx_http_spdy_terminate_stream(sc, stream,
+ NGX_SPDY_PROTOCOL_ERROR)
+ != NGX_OK)
+ {
+ return ngx_http_spdy_state_internal_error(sc);
+ }
+ }
+
+ return ngx_http_spdy_state_protocol_error(sc);
+ }
+
+ sc->last_sid = sid;
+
sscf = ngx_http_get_module_srv_conf(sc->http_connection->conf_ctx,
ngx_http_spdy_module);
@@ -968,8 +989,6 @@ ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, u_char *pos,
sc->stream = stream;
- sc->last_sid = sid;
-
return ngx_http_spdy_state_headers(sc, pos, end);
}