Skip to content

Commit

Permalink
http2: don't overflow stream IDs in server push
Browse files Browse the repository at this point in the history
The max allowed stream ID is 2^31-1. The RFC says that we should send
GOAWAY if the ID space is exhausted.

Change-Id: I0042cb4e1f8781a2ece5a5f06f498eb06192da7f
Reviewed-on: https://go-review.googlesource.com/32488
Run-TryBot: Brad Fitzpatrick <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
tombergan authored and bradfitz committed Nov 8, 2016
1 parent e36fcd2 commit 40d3034
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,12 @@ func (sc *serverConn) startPush(msg startPushRequest) {

// http://tools.ietf.org/html/rfc7540#section-5.1.1.
// Streams initiated by the server MUST use even-numbered identifiers.
// A server that is unable to establish a new stream identifier can send a GOAWAY
// frame so that the client is forced to open a new connection for new streams.
if sc.maxPushPromiseID+2 >= 1<<31 {
sc.goAwayIn(ErrCodeNo, 0)
return 0, ErrPushLimitReached
}
sc.maxPushPromiseID += 2
promisedID := sc.maxPushPromiseID

Expand Down

0 comments on commit 40d3034

Please sign in to comment.