Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8a401f

Browse files
committed
fix(session): reject cmdUPD in protocol version 1
cmdUPD is a v2-only command used for flow control window updates. Previously, recvLoop would accept and process cmdUPD even when the session was configured for protocol version 1, which violates the protocol specification. This change adds a version check before processing cmdUPD. If the session is not running v2, it now correctly returns ErrInvalidProtocol and terminates the receive loop.
1 parent 8dbcbb3 commit c8a401f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

session.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,12 @@ func (s *Session) recvLoop() {
468468
}
469469
s.streamLock.Unlock()
470470

471-
case cmdUPD: // a window update signal
471+
case cmdUPD: // a window update signal (v2 only)
472+
if s.config.Version != 2 {
473+
s.notifyProtoError(ErrInvalidProtocol)
474+
return
475+
}
476+
472477
_, err := io.ReadFull(s.conn, updHdr[:])
473478
if err != nil {
474479
s.notifyReadError(err)

0 commit comments

Comments
 (0)