Added guard in ioctlSetAddr for nil IP
This commit is contained in:
@@ -11,6 +11,7 @@ package wginterface
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -173,6 +174,10 @@ func nlAttr(attrType uint16, data []byte) []byte {
|
|||||||
// messages, but the AF_INET ioctl interface is simpler.
|
// messages, but the AF_INET ioctl interface is simpler.
|
||||||
|
|
||||||
func ioctlSetAddr(name string, ip net.IP, prefixLen int) error {
|
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)
|
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, unix.IPPROTO_IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user