tun: windows: inform wintun of maximum buffer length for writes

This commit is contained in:
Jason A. Donenfeld 2019-06-26 13:27:48 +02:00
parent c69d026649
commit 5e6eff81b6

View file

@ -141,6 +141,12 @@ func (tun *NativeTun) openTUN() error {
} }
return err 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 return nil
} }