5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 11:50:28 +00:00

Fix panic where slice goes out of bounds because iface.Read returns less than zero (which might happen when the TUN/TAP interface is closed)

This commit is contained in:
Neil Alexander 2019-09-18 14:05:18 +01:00
parent 368f499f1d
commit 94cf2854a9
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -111,7 +111,7 @@ func (r *tunReader) _read() {
recvd := util.ResizeBytes(util.GetBytes(), 65535+tun_ETHER_HEADER_LENGTH)
// Wait for a packet to be delivered to us through the TUN/TAP adapter
n, err := r.tun.iface.Read(recvd)
if n == 0 {
if n <= 0 {
util.PutBytes(recvd)
} else {
r.tun.handlePacketFrom(r, recvd[:n], err)