Ver código fonte

Fix use of unprotected `stream.sendHdr` in session (#100)

We now create a new header slice instead of taking a `sendLock` as this
is a rare occurance.
Mathias Fredriksson 2 anos atrás
pai
commit
962ff9cfcc
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      session.go

+ 3 - 2
session.go

@@ -639,8 +639,9 @@ func (s *Session) incomingStream(id uint32) error {
 		// Backlog exceeded! RST the stream
 		s.logger.Printf("[WARN] yamux: backlog exceeded, forcing connection reset")
 		delete(s.streams, id)
-		stream.sendHdr.encode(typeWindowUpdate, flagRST, id, 0)
-		return s.sendNoWait(stream.sendHdr)
+		hdr := header(make([]byte, headerSize))
+		hdr.encode(typeWindowUpdate, flagRST, id, 0)
+		return s.sendNoWait(hdr)
 	}
 }