manage invalid error code (size=1) and too long reason (size>125)

This commit is contained in:
xdrm-brackets 2018-05-06 01:06:17 +02:00
parent ec1722a804
commit f07afb8c85
1 changed files with 8 additions and 6 deletions

View File

@ -156,12 +156,14 @@ func clientReader(c *client){
/* (4) CLOSE */ /* (4) CLOSE */
if msg.Type == CLOSE { if msg.Type == CLOSE {
// fmt.Printf(" [reader] CLOSE ; size %d\n", msg.Size) // uncomplete code || too long
// if msg.Size >= 2 { if msg.Size == 1 || msg.Size > 125 {
// errCode := binary.BigEndian.Uint16(msg.Data[0:2]) errorCode = PROTOCOL_ERR
// fmt.Printf(" ; status %d\n", errCode) }
// fmt.Printf(" ; msg '%s'\n", msg.Data[2:]) // invalid utf-8 reason
// } if msg.Size > 2 && !utf8.Valid(msg.Data[2:]) {
errorCode = INVALID_PAYLOAD
}
clientAck = false clientAck = false
break break