Skip to content

syscall: ParseRoutingSockaddr crushes notified network addresses #8203

Closed
@gopherbot

Description

@gopherbot

by [email protected]:

What does 'go version' print?

go version devel +0f7c69d6c367 Mon May 12 17:19:02 2014 -0400 darwin/amd64

What steps reproduce the problem?

Parse RTM_NEWADDR messages on a mac.

If possible, include a link to a program on play.golang.org. (I attached one as a file)

1.  read the PF_ROUTE socket
2.  parse messages using syscall.ParseRoutingMessage and syscall.ParseRoutingSockaddr
3.  turn wifi off and on


What happened?

You'll get back a netmask and a bogus address.
The pkg code is wrong, see fix below.

What should have happened instead?

You get back a netmask and a good address.

Please provide any additional information below.

go/src/pkg/syscall/route_bsd.go:156

was:
        if m.Header.Addrs&rtaIfaMask&(1<<i) == 0 {

should be:
        if m.Header.Addrs&(1<<i) == 0 {

Otherwise the subsequent loop gets confused about what address it is parsing, i.e, it
doesn't skip over the ones its trying to ignore.   Easy fix.

Attachments:

  1. broken.go (1474 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions