diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-07-18 19:34:45 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-07-18 19:34:45 +0200 |
commit | 7bc0e118317d20974107a8a0f17cf57d400f4791 (patch) | |
tree | 24cceaab8de39dbc3e54e6db7ebae20c97db2b76 /device | |
parent | 31ff9c02fec42f38b0e444c41744887a1b9fedaf (diff) |
device: do not crash on nil'd bind in windows binding
Diffstat (limited to 'device')
-rw-r--r-- | device/boundif_windows.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/device/boundif_windows.go b/device/boundif_windows.go index b842ba8..7879a43 100644 --- a/device/boundif_windows.go +++ b/device/boundif_windows.go @@ -7,6 +7,7 @@ package device import ( "encoding/binary" + "errors" "unsafe" "golang.org/x/sys/windows" @@ -23,6 +24,10 @@ func (device *Device) BindSocketToInterface4(interfaceIndex uint32) error { binary.BigEndian.PutUint32(bytes, interfaceIndex) interfaceIndex = *(*uint32)(unsafe.Pointer(&bytes[0])) + if device.net.bind == nil { + return errors.New("Bind is not yet initialized") + } + sysconn, err := device.net.bind.(*nativeBind).ipv4.SyscallConn() if err != nil { return err |