From: Jason A. Donenfeld Date: Wed, 26 Jun 2019 11:27:48 +0000 (+0200) Subject: tun: windows: inform wintun of maximum buffer length for writes X-Git-Tag: 0.0.20190805~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e6eff81b6f7f18b3dd24bec03ea71f009a3e938;p=thirdparty%2Fwireguard-go.git tun: windows: inform wintun of maximum buffer length for writes --- 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 }