mirror of
https://github.com/golang/go
synced 2024-09-25 01:20:13 -06:00
syscall: skip routing messages with mismatched version
Skip routing messages with a mismatched version, rather than failing and returning EINVAL. Only return EINVAL if we were unable to parse any of the routing messages (presumably due to a version mismatch). R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/30340043
This commit is contained in:
parent
c8869e9caf
commit
517e49eb29
@ -199,14 +199,21 @@ func (m *InterfaceAddrMessage) sockaddr() (sas []Sockaddr) {
|
||||
// ParseRoutingMessage parses b as routing messages and returns the
|
||||
// slice containing the RoutingMessage interfaces.
|
||||
func ParseRoutingMessage(b []byte) (msgs []RoutingMessage, err error) {
|
||||
msgCount := 0
|
||||
for len(b) >= anyMessageLen {
|
||||
msgCount++
|
||||
any := (*anyMessage)(unsafe.Pointer(&b[0]))
|
||||
if any.Version != RTM_VERSION {
|
||||
return nil, EINVAL
|
||||
b = b[any.Msglen:]
|
||||
continue
|
||||
}
|
||||
msgs = append(msgs, any.toRoutingMessage(b))
|
||||
b = b[any.Msglen:]
|
||||
}
|
||||
// We failed to parse any of the messages - version mismatch?
|
||||
if msgCount > 0 && len(msgs) == 0 {
|
||||
return nil, EINVAL
|
||||
}
|
||||
return msgs, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user