diff --git a/server/ws_wrapper.go b/server/ws_wrapper.go index 819c393..aa3816f 100644 --- a/server/ws_wrapper.go +++ b/server/ws_wrapper.go @@ -1,7 +1,10 @@ package server import ( + "io/ioutil" + "github.com/gorilla/websocket" + "github.com/pkg/errors" ) type wsWrapper struct { @@ -28,6 +31,11 @@ func (wsw *wsWrapper) Read(p []byte) (n int, err error) { continue } - return reader.Read(p) + b, err := ioutil.ReadAll(reader) + if len(b) > len(p) { + return 0, errors.Wrapf(err, "Client message exceeded buffer size") + } + n = copy(p, b) + return n, err } }