aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tunnel
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-09-26 18:41:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-09-27 10:44:35 +0200
commitad84c01056283ea4f1dedcbe728103b86aed6395 (patch)
treeb591f01c88537906e886fc5d8de06d470ca7cbae /tunnel
parentui: always show manage page on tray click (diff)
downloadwireguard-windows-ad84c01056283ea4f1dedcbe728103b86aed6395.tar.xz
wireguard-windows-ad84c01056283ea4f1dedcbe728103b86aed6395.zip
winipcfg: ensure we're passing copy to go routines
The windows-allocated one gets freed. Reported-by: Odd Stranne <odd@mullvad.net>
Diffstat (limited to 'tunnel')
-rw-r--r--tunnel/winipcfg/interface_change_handler.go3
-rw-r--r--tunnel/winipcfg/route_change_handler.go3
-rw-r--r--tunnel/winipcfg/unicast_address_change_handler.go3
3 files changed, 6 insertions, 3 deletions
diff --git a/tunnel/winipcfg/interface_change_handler.go b/tunnel/winipcfg/interface_change_handler.go
index 50ea6448..57041719 100644
--- a/tunnel/winipcfg/interface_change_handler.go
+++ b/tunnel/winipcfg/interface_change_handler.go
@@ -64,9 +64,10 @@ func (callback *InterfaceChangeCallback) Unregister() error {
}
func interfaceChanged(callerContext uintptr, row *MibIPInterfaceRow, notificationType MibNotificationType) uintptr {
+ rowCopy := *row
interfaceChangeMutex.Lock()
for cb := range interfaceChangeCallbacks {
- go cb.cb(notificationType, row)
+ go cb.cb(notificationType, &rowCopy)
}
interfaceChangeMutex.Unlock()
return 0
diff --git a/tunnel/winipcfg/route_change_handler.go b/tunnel/winipcfg/route_change_handler.go
index 4bdea672..cafa0e97 100644
--- a/tunnel/winipcfg/route_change_handler.go
+++ b/tunnel/winipcfg/route_change_handler.go
@@ -71,9 +71,10 @@ func (callback *RouteChangeCallback) Unregister() error {
}
func routeChanged(callerContext uintptr, row *MibIPforwardRow2, notificationType MibNotificationType) uintptr {
+ rowCopy := *row
routeChangeMutex.Lock()
for cb := range routeChangeCallbacks {
- go cb.cb(notificationType, row)
+ go cb.cb(notificationType, &rowCopy)
}
routeChangeMutex.Unlock()
return 0
diff --git a/tunnel/winipcfg/unicast_address_change_handler.go b/tunnel/winipcfg/unicast_address_change_handler.go
index b126e2ed..fdd2e058 100644
--- a/tunnel/winipcfg/unicast_address_change_handler.go
+++ b/tunnel/winipcfg/unicast_address_change_handler.go
@@ -64,9 +64,10 @@ func (callback *UnicastAddressChangeCallback) Unregister() error {
}
func unicastAddressChanged(callerContext uintptr, row *MibUnicastIPAddressRow, notificationType MibNotificationType) uintptr {
+ rowCopy := *row
unicastAddressChangeMutex.Lock()
for cb := range unicastAddressChangeCallbacks {
- go cb.cb(notificationType, row)
+ go cb.cb(notificationType, &rowCopy)
}
unicastAddressChangeMutex.Unlock()
return 0