1
0
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:
Mathias Hall-Andersen 2017-07-18 14:15:29 +02:00
parent c5d7efc246
commit bd6027a4d5
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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