mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Make sure to always read full messages.
This commit is contained in:
parent
c3be7e6b4f
commit
91b83edf9c
1 changed files with 6 additions and 3 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"goprotobuf.googlecode.com/hg/proto"
|
"goprotobuf.googlecode.com/hg/proto"
|
||||||
"mumbleproto"
|
"mumbleproto"
|
||||||
"cryptstate"
|
"cryptstate"
|
||||||
|
"io"
|
||||||
"packetdatastream"
|
"packetdatastream"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -176,8 +177,10 @@ func (client *Client) RejectAuth(kind, reason string) {
|
||||||
|
|
||||||
// Read a protobuf message from a client
|
// Read a protobuf message from a client
|
||||||
func (client *Client) readProtoMessage() (msg *Message, err os.Error) {
|
func (client *Client) readProtoMessage() (msg *Message, err os.Error) {
|
||||||
var length uint32
|
var (
|
||||||
var kind uint16
|
length uint32
|
||||||
|
kind uint16
|
||||||
|
)
|
||||||
|
|
||||||
// Read the message type (16-bit big-endian unsigned integer)
|
// Read the message type (16-bit big-endian unsigned integer)
|
||||||
err = binary.Read(client.reader, binary.BigEndian, &kind)
|
err = binary.Read(client.reader, binary.BigEndian, &kind)
|
||||||
|
|
@ -194,7 +197,7 @@ func (client *Client) readProtoMessage() (msg *Message, err os.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, length)
|
buf := make([]byte, length)
|
||||||
_, err = client.reader.Read(buf)
|
_, err = io.ReadFull(client.reader, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Panic("Unable to read packet content")
|
client.Panic("Unable to read packet content")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue