From 1eed97f0f86597161b7e4b78b61a5901422e9d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20L=2E=20Hansen?= Date: Thu, 31 Mar 2022 10:42:51 -0700 Subject: [PATCH] Make sure we read the full message --- server/ws_wrapper.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 } }