manage invalid error code (size=1) and too long reason (size>125)
This commit is contained in:
parent
ec1722a804
commit
f07afb8c85
14
ws/client.go
14
ws/client.go
|
@ -156,12 +156,14 @@ func clientReader(c *client){
|
|||
|
||||
/* (4) CLOSE */
|
||||
if msg.Type == CLOSE {
|
||||
// fmt.Printf(" [reader] CLOSE ; size %d\n", msg.Size)
|
||||
// if msg.Size >= 2 {
|
||||
// errCode := binary.BigEndian.Uint16(msg.Data[0:2])
|
||||
// fmt.Printf(" ; status %d\n", errCode)
|
||||
// fmt.Printf(" ; msg '%s'\n", msg.Data[2:])
|
||||
// }
|
||||
// uncomplete code || too long
|
||||
if msg.Size == 1 || msg.Size > 125 {
|
||||
errorCode = PROTOCOL_ERR
|
||||
}
|
||||
// invalid utf-8 reason
|
||||
if msg.Size > 2 && !utf8.Valid(msg.Data[2:]) {
|
||||
errorCode = INVALID_PAYLOAD
|
||||
}
|
||||
clientAck = false
|
||||
break
|
||||
|
||||
|
|
Loading…
Reference in New Issue