summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-12-17 13:26:58 +0900
committerLorenzo Colitti <lorenzo@google.com>2015-02-02 17:47:30 +0900
commita014279741d26eb857e6f5a01c5d2fc040cf7b8f (patch)
tree34eefbfed7cec78623908409dd61897c3986b16e /tests
parentcbcbda6d3d8b0c208590cd769bdcf044396ee68a (diff)
downloadextras-a014279741d26eb857e6f5a01c5d2fc040cf7b8f.tar.gz
Add a test for cross-protocol ping crash.
Change-Id: Idfea9137d77675c15c8f11f4e9603ca79c49f997
Diffstat (limited to 'tests')
-rwxr-xr-xtests/net_test/ping6_test.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/net_test/ping6_test.py b/tests/net_test/ping6_test.py
index 7b51ac43..b09d63a7 100755
--- a/tests/net_test/ping6_test.py
+++ b/tests/net_test/ping6_test.py
@@ -167,6 +167,30 @@ class Ping6Test(net_test.NetworkTest):
reply = posix.read(fd, 4096)
self.assertEquals(written, len(reply))
+ def testCrossProtocolCrash(self):
+
+ def GetIPv4Unreachable(port):
+ return (scapy.IP(src="192.0.2.1", dst="127.0.0.1") /
+ scapy.ICMP(type=3, code=0) /
+ scapy.IP(src="127.0.0.1", dst="127.0.0.1") /
+ scapy.ICMP(type=8, id=port, seq=1))
+
+ def GetIPv6Unreachable(port):
+ return (scapy.IPv6(src="::1", dst="::1") /
+ scapy.ICMPv6DestUnreach() /
+ scapy.IPv6(src="::1", dst="::1") /
+ scapy.ICMPv6EchoRequest(id=port, seq=1, data="foobarbaz"))
+
+ # An unreachable matching the ID of a socket of the wrong protocol
+ # shouldn't crash. We can only test this using IPv6 unreachables and IPv4
+ # ping sockets, because IPv4 packets sent by scapy.send() on loopback don't
+ # appear to be received by the kernel.)
+ s = net_test.IPv4PingSocket()
+ s.connect(("127.0.0.1", 12345))
+ _, port = s.getsockname()
+ scapy.send(GetIPv6Unreachable(port))
+ # No crash? Good.
+
@unittest.skipUnless(net_test.HAVE_IPV4, "skipping: no IPv4")
def testIPv4Bind(self):