aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-26 13:27:48 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-26 13:27:48 +0200
commit5e6eff81b6f7f18b3dd24bec03ea71f009a3e938 (patch)
tree4455136832e529cdcf39949d6214f72205d37698
parenttun: windows: never retry open on Windows 10 (diff)
downloadwireguard-go-5e6eff81b6f7f18b3dd24bec03ea71f009a3e938.tar.xz
wireguard-go-5e6eff81b6f7f18b3dd24bec03ea71f009a3e938.zip
tun: windows: inform wintun of maximum buffer length for writes
-rw-r--r--tun/tun_windows.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 05fc3df..1de74e6 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -141,6 +141,12 @@ func (tun *NativeTun) openTUN() error {
}
return err
}
+ firstSize := (*uint32)(unsafe.Pointer(&tun.wrBuff.data[0]))
+ saved := *firstSize
+ *firstSize = 0
+ // Set the maximum buffer length with an invalid write.
+ tun.tunFileWrite.Write(tun.wrBuff.data[:])
+ *firstSize = saved
}
return nil
}