mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Reinstate length/bounds check in tun.go
This commit is contained in:
		
							parent
							
								
									0240375417
								
							
						
					
					
						commit
						a3a53f92c3
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
					@ -101,11 +101,11 @@ func (tun *tunDevice) read() error {
 | 
				
			||||||
		if tun.iface.IsTAP() {
 | 
							if tun.iface.IsTAP() {
 | 
				
			||||||
			o = tun_ETHER_HEADER_LENGTH
 | 
								o = tun_ETHER_HEADER_LENGTH
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if buf[o]&0xf0 != 0x60 ||
 | 
							switch {
 | 
				
			||||||
			n != 256*int(buf[o+4])+int(buf[o+5])+tun_IPv6_HEADER_LENGTH+o {
 | 
							case 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
 | 
							case buf[o]&0xf0 == 0x40 && n == 256*int(buf[o+2])+int(buf[o+3])+o:
 | 
				
			||||||
			//panic("Should not happen in testing")
 | 
							default:
 | 
				
			||||||
			//continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if buf[o+6] == 58 {
 | 
							if buf[o+6] == 58 {
 | 
				
			||||||
			// Found an ICMPv6 packet
 | 
								// Found an ICMPv6 packet
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue