Commit 96e9e81b authored by Russ Cox's avatar Russ Cox

syscall: fix ParseRoutingSockaddr with unexpected submessages

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
parent ea295a4c
...@@ -153,7 +153,7 @@ func (m *InterfaceAddrMessage) sockaddr() (sas []Sockaddr) { ...@@ -153,7 +153,7 @@ func (m *InterfaceAddrMessage) sockaddr() (sas []Sockaddr) {
// RTAX_NETMASK socket address on the FreeBSD kernel. // RTAX_NETMASK socket address on the FreeBSD kernel.
preferredFamily := uint8(AF_UNSPEC) preferredFamily := uint8(AF_UNSPEC)
for i := uint(0); i < RTAX_MAX; i++ { for i := uint(0); i < RTAX_MAX; i++ {
if m.Header.Addrs&rtaIfaMask&(1<<i) == 0 { if m.Header.Addrs&(1<<i) == 0 {
continue continue
} }
rsa := (*RawSockaddr)(unsafe.Pointer(&b[0])) rsa := (*RawSockaddr)(unsafe.Pointer(&b[0]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment