mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
Fixed file descriptor leak on linux
This commit is contained in:
parent
c5d7efc246
commit
bd6027a4d5
@ -313,17 +313,15 @@ func (device *Device) RoutineEncryption() {
|
||||
elem.packet = append(elem.packet, 0)
|
||||
}
|
||||
|
||||
// encrypt content
|
||||
// encrypt content (append to header)
|
||||
|
||||
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
|
||||
elem.packet = elem.keyPair.send.Seal(
|
||||
elem.packet[:0],
|
||||
header,
|
||||
nonce[:],
|
||||
elem.packet,
|
||||
nil,
|
||||
)
|
||||
length := MessageTransportHeaderSize + len(elem.packet)
|
||||
elem.packet = elem.buffer[:length]
|
||||
elem.mutex.Unlock()
|
||||
|
||||
// refresh key if necessary
|
||||
|
@ -37,6 +37,8 @@ func (tun *NativeTun) setMTU(n int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer syscall.Close(fd)
|
||||
|
||||
// do ioctl call
|
||||
|
||||
var ifr [64]byte
|
||||
@ -70,6 +72,8 @@ func (tun *NativeTun) MTU() (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
defer syscall.Close(fd)
|
||||
|
||||
// do ioctl call
|
||||
|
||||
var ifr [64]byte
|
||||
|
Loading…
Reference in New Issue
Block a user