diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/syscall/route_bsd.go | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-51f2ca399fb8da86b2e7b3a0582e083fab731a98.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/syscall/route_bsd.go')
-rw-r--r-- | src/pkg/syscall/route_bsd.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pkg/syscall/route_bsd.go b/src/pkg/syscall/route_bsd.go index 638073592..48af58745 100644 --- a/src/pkg/syscall/route_bsd.go +++ b/src/pkg/syscall/route_bsd.go @@ -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 } |