Added guard in ioctlSetAddr for nil IP
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user