Commit 75d3d53c authored by Mikio Hara's avatar Mikio Hara

go.net/ipv4: don't set ifindex to negative integers

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/171810043
parent 3a0acf56
......@@ -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)
}
}
......
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