]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: fix crash when ForceMTU is called after close
authorJames Tucker <james@tailscale.com>
Wed, 27 Sep 2023 21:52:21 +0000 (14:52 -0700)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 10 Oct 2023 13:37:17 +0000 (15:37 +0200)
Close closes the events channel, resulting in a panic from send on
closed channel.

Reported-By: Brad Fitzpatrick <brad@tailscale.com>
Signed-off-by: James Tucker <james@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
tun/tun_windows.go

index 0cb4ce1925da4b9dc5be8873450bdf43be065b7d..34f29805da1dc9431e3691ddb1ddbdadd7c3fabb 100644 (file)
@@ -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 {