Reject Index and Request messages with unexpected flags

This commit is contained in:
Jakob Borg 2015-01-11 13:25:22 +01:00
parent 7a0a702ec0
commit cd34eea017

View File

@ -295,6 +295,11 @@ func (c *rawConnection) readerLoop() (err error) {
switch msg := msg.(type) { switch msg := msg.(type) {
case IndexMessage: case IndexMessage:
if msg.Flags != 0 {
// We don't currently support or expect any flags.
return fmt.Errorf("protocol error: unknown flags 0x%x in Index(Update) message", msg.Flags)
}
switch hdr.msgType { switch hdr.msgType {
case messageTypeIndex: case messageTypeIndex:
if c.state < stateCCRcvd { if c.state < stateCCRcvd {
@ -311,6 +316,10 @@ func (c *rawConnection) readerLoop() (err error) {
} }
case RequestMessage: case RequestMessage:
if msg.Flags != 0 {
// We don't currently support or expect any flags.
return fmt.Errorf("protocol error: unknown flags 0x%x in Request message", msg.Flags)
}
if c.state < stateIdxRcvd { if c.state < stateIdxRcvd {
return fmt.Errorf("protocol error: request message in state %d", c.state) return fmt.Errorf("protocol error: request message in state %d", c.state)
} }