From 12b601cfcdabe5547820f0f7582705b7fea084d1 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 17 Apr 2020 21:49:10 +0500 Subject: [PATCH] Add some check --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index 7a667c4..e1d397b 100755 --- a/main.py +++ b/main.py @@ -160,6 +160,9 @@ def handle_ip_packet(ip_packet, conn, tun_iface, config): ip_packet_packed = ip_packet.to_byte_string() 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 if ip_packet.header.dst == config.iface_addr: