mirror of
https://github.com/golang/net.git
synced 2026-04-01 02:47:08 +09:00
http2: don't overflow stream IDs in server push
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 <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
e36fcd2311
commit
40d3034e57
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user