1
0
Fork 0

Add some check

This commit is contained in:
Alex Kotov 2020-04-17 21:49:10 +05:00
parent b74ebe03b4
commit 12b601cfcd
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 3 additions and 0 deletions

View File

@ -160,6 +160,9 @@ def handle_ip_packet(ip_packet, conn, tun_iface, config):
ip_packet_packed = ip_packet.to_byte_string() ip_packet_packed = ip_packet.to_byte_string()
ip_packet_length = struct.pack('>I', len(ip_packet_packed)) ip_packet_length = struct.pack('>I', len(ip_packet_packed))
if len(ip_packet_packed) != ip_packet.header.total_length:
raise RuntimeError('invalid "total length" header value')
buf = MAGIC + ip_packet_length + ip_packet_packed buf = MAGIC + ip_packet_length + ip_packet_packed
if ip_packet.header.dst == config.iface_addr: if ip_packet.header.dst == config.iface_addr: