]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: fix ParseRoutingSockaddr with unexpected submessages
authorRuss Cox <rsc@golang.org>
Tue, 28 Oct 2014 15:35:00 +0000 (11:35 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 28 Oct 2014 15:35:00 +0000 (11:35 -0400)
No easy way to test (would have to actually trigger some routing
events from kernel) but the code is clearly wrong as written.
If the header says there is a submessage, we need to at least
skip over its bytes, not just continue to the next iteration.

Fixes #8203.

LGTM=r
R=r
CC=golang-codereviews, mikioh.mikioh, p
https://golang.org/cl/164140044

src/syscall/route_bsd.go

index 48af587450ba1eca15cbd56abc775c41f3c36670..1dabe42531b77da5e407d7f1009de20129e697a8 100644 (file)
@@ -153,7 +153,7 @@ func (m *InterfaceAddrMessage) sockaddr() (sas []Sockaddr) {
        // RTAX_NETMASK socket address on the FreeBSD kernel.
        preferredFamily := uint8(AF_UNSPEC)
        for i := uint(0); i < RTAX_MAX; i++ {
-               if m.Header.Addrs&rtaIfaMask&(1<<i) == 0 {
+               if m.Header.Addrs&(1<<i) == 0 {
                        continue
                }
                rsa := (*RawSockaddr)(unsafe.Pointer(&b[0]))