]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: windows: inform wintun of maximum buffer length for writes
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 26 Jun 2019 11:27:48 +0000 (13:27 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 26 Jun 2019 11:27:48 +0000 (13:27 +0200)
tun/tun_windows.go

index 05fc3dff25548dbb110fedb2ba29941d6a81336c..1de74e688657c203c0749f69ee7ccf4b10c28dfc 100644 (file)
@@ -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
 }