From a3a53f92c3891d531df9b9cc2c0a05412950e744 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 6 Nov 2018 22:35:28 +0000 Subject: [PATCH] Reinstate length/bounds check in tun.go --- src/yggdrasil/tun.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yggdrasil/tun.go b/src/yggdrasil/tun.go index ac70398..1987c2d 100644 --- a/src/yggdrasil/tun.go +++ b/src/yggdrasil/tun.go @@ -101,11 +101,11 @@ func (tun *tunDevice) read() error { if tun.iface.IsTAP() { o = tun_ETHER_HEADER_LENGTH } - if buf[o]&0xf0 != 0x60 || - n != 256*int(buf[o+4])+int(buf[o+5])+tun_IPv6_HEADER_LENGTH+o { - // Either not an IPv6 packet or not the complete packet for some reason - //panic("Should not happen in testing") - //continue + switch { + case buf[o]&0xf0 == 0x60 && n == 256*int(buf[o+4])+int(buf[o+5])+tun_IPv6_HEADER_LENGTH+o: + case buf[o]&0xf0 == 0x40 && n == 256*int(buf[o+2])+int(buf[o+3])+o: + default: + continue } if buf[o+6] == 58 { // Found an ICMPv6 packet