Make sure we read the full message

This commit is contained in:
Søren L. Hansen 2022-03-31 10:42:51 -07:00
parent 82c3acf3b1
commit 1eed97f0f8

View File

@ -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
}
}