mirror of
https://github.com/golang/net.git
synced 2026-04-01 02:47:08 +09:00
go.net/ipv4: don't set ifindex to negative integers
LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/171810043
This commit is contained in:
@@ -23,7 +23,7 @@ func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
|
||||
if ip := cm.Src.To4(); ip != nil {
|
||||
copy(pi.Spec_dst[:], ip)
|
||||
}
|
||||
if cm.IfIndex != 0 {
|
||||
if cm.IfIndex > 0 {
|
||||
pi.setIfindex(cm.IfIndex)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func marshalControlMessage(cm *ControlMessage) (oob []byte) {
|
||||
}
|
||||
var l int
|
||||
if ctlOpts[ctlPacketInfo].name > 0 {
|
||||
if cm.Src.To4() != nil || cm.IfIndex != 0 {
|
||||
if cm.Src.To4() != nil || cm.IfIndex > 0 {
|
||||
l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length)
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func marshalControlMessage(cm *ControlMessage) (oob []byte) {
|
||||
oob = make([]byte, l)
|
||||
b := oob
|
||||
if ctlOpts[ctlPacketInfo].name > 0 {
|
||||
if cm.Src.To4() != nil || cm.IfIndex != 0 {
|
||||
if cm.Src.To4() != nil || cm.IfIndex > 0 {
|
||||
b = ctlOpts[ctlPacketInfo].marshal(b, cm)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user