From: James Tucker Date: Wed, 27 Sep 2023 21:52:21 +0000 (-0700) Subject: tun: fix crash when ForceMTU is called after close X-Git-Tag: 0.0.20250515~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec8f6f82c20c617a3ea94478f2b5e4d49c6d3c2c;p=thirdparty%2Fwireguard-go.git tun: fix crash when ForceMTU is called after close Close closes the events channel, resulting in a panic from send on closed channel. Reported-By: Brad Fitzpatrick Signed-off-by: James Tucker Signed-off-by: Jason A. Donenfeld --- diff --git a/tun/tun_windows.go b/tun/tun_windows.go index 0cb4ce1..34f2980 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -127,6 +127,9 @@ func (tun *NativeTun) MTU() (int, error) { // TODO: This is a temporary hack. We really need to be monitoring the interface in real time and adapting to MTU changes. func (tun *NativeTun) ForceMTU(mtu int) { + if tun.close.Load() { + return + } update := tun.forcedMTU != mtu tun.forcedMTU = mtu if update {