mirror of
https://github.com/golang/net.git
synced 2026-03-31 02:17:08 +09:00
ipv4: fix unsafe pointer conversion in parseInterface
Fixes golang/go#35174 Change-Id: I01ae0ec25c90da0d05b1b262b33a32233f88260f Reviewed-on: https://go-review.googlesource.com/c/net/+/203400 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
83d349e8ac
commit
d64ee3fa51
@@ -35,6 +35,7 @@ func marshalInterface(b []byte, cm *ControlMessage) []byte {
|
||||
}
|
||||
|
||||
func parseInterface(cm *ControlMessage, b []byte) {
|
||||
sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0]))
|
||||
var sadl syscall.SockaddrDatalink
|
||||
copy((*[unsafe.Sizeof(&sadl)]byte)(unsafe.Pointer(&sadl))[:], b)
|
||||
cm.IfIndex = int(sadl.Index)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user