Skip to content

Commit 044c308

Browse files
committed
quic: check for packet overflow when writing MAX_STREAMS
Return a bool from remoteStreamLimits.appendFrame indicating whether the packet had space for all appended frames, matching the pattern of other functions that write frames. For golang/go#58547 Change-Id: If21d1b192cea210b94a0c6ce996a73fe43b3babe Reviewed-on: https://go-review.googlesource.com/c/net/+/526755 Reviewed-by: Jonathan Amsterdam <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 5401f76 commit 044c308

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

internal/quic/conn_streams.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,14 @@ func (c *Conn) queueStreamForSend(s *Stream) {
212212
// It returns true if no more frames need appending,
213213
// false if not everything fit in the current packet.
214214
func (c *Conn) appendStreamFrames(w *packetWriter, pnum packetNumber, pto bool) bool {
215-
c.streams.remoteLimit[uniStream].appendFrame(w, uniStream, pnum, pto)
216-
c.streams.remoteLimit[bidiStream].appendFrame(w, bidiStream, pnum, pto)
215+
// MAX_STREAM_DATA
216+
if !c.streams.remoteLimit[uniStream].appendFrame(w, uniStream, pnum, pto) {
217+
return false
218+
}
219+
if !c.streams.remoteLimit[bidiStream].appendFrame(w, bidiStream, pnum, pto) {
220+
return false
221+
}
222+
217223
if pto {
218224
return c.appendStreamFramesPTO(w, pnum)
219225
}

internal/quic/stream_limits.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ func (lim *remoteStreamLimits) maybeUpdateMax() {
9898
}
9999
}
100100

101-
// appendFrame appends a MAX_DATA frame if necessary.
102-
func (lim *remoteStreamLimits) appendFrame(w *packetWriter, typ streamType, pnum packetNumber, pto bool) {
103-
if !lim.sendMax.shouldSendPTO(pto) {
104-
return
105-
}
106-
if w.appendMaxStreamsFrame(typ, lim.max) {
101+
// appendFrame appends a MAX_STREAMS frame to the current packet, if necessary.
102+
//
103+
// It returns true if no more frames need appending,
104+
// false if not everything fit in the current packet.
105+
func (lim *remoteStreamLimits) appendFrame(w *packetWriter, typ streamType, pnum packetNumber, pto bool) bool {
106+
if lim.sendMax.shouldSendPTO(pto) {
107+
if !w.appendMaxStreamsFrame(typ, lim.max) {
108+
return false
109+
}
107110
lim.sendMax.setSent(pnum)
108111
}
112+
return true
109113
}

0 commit comments

Comments
 (0)