Added guard in ioctlSetAddr for nil IP

This commit is contained in:
jdl
2026-06-13 08:48:42 +02:00
parent 98f07457b9
commit f3d8a9ff75

View File

@@ -11,6 +11,7 @@ package wginterface
import (
"encoding/binary"
"errors"
"fmt"
"net"
"slices"
@@ -173,6 +174,10 @@ func nlAttr(attrType uint16, data []byte) []byte {
// messages, but the AF_INET ioctl interface is simpler.
func ioctlSetAddr(name string, ip net.IP, prefixLen int) error {
if ip.To4() == nil {
return errors.New("attempted to set nil IP on interface")
}
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, unix.IPPROTO_IP)
if err != nil {
return err