Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
x/net/websocket: Read/Copy fail with long frames #2134
When using io.Copy() with a websocket as source, this fails if incoming websocket frames are too large. The reason is because io.Copy() uses a buffer with a default size for the Read(). websocket.Read() in turn uses bufio.ReadSlice() to read the current frame up to the final 0xff. But if the incoming websocket frame size exceeds the buffer size of io.Copy(), a ErrBufferFull ("bufio: buffer full") is generated. The websocket specification does not limit the size of a frame, so this behaviour is somewhat undesirable, as the success of a io.Copy() depends on the size of internal buffers and the undeterminable websocket frame size. What steps will reproduce the problem? 1. One process needs to open a websocket connection to a Go websocket server (pseudo code, obviously): ws := websocket.Dial("127.0.0.1:80") buf := make(byte, 100000) ws.Write(buf) 2. Websocket server: ws := accepted websocket.Conn writer := io.Writer err := io.Copy(writer, ws) What is the expected output? err == nil What do you see instead? err == bufio.ErrBufferFull Which revision are you using? (hg identify) 1b38d90eebcd+ (release-branch.r58) tip (patches applied at other locations)
So we retired x/net/websocket with an advisory https://pkg.go.dev/golang.org/x/net/websocket?tab=doc to instead use
And thus I shall close this issue.