diff options
author | teor <teor@torproject.org> | 2019-06-13 23:15:52 +1000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-06-26 09:55:37 -0400 |
commit | 60ce431c5440ee08e100a1f70a4d7224b7dc9c21 (patch) | |
tree | 24551ad71f3e1d42a55defd5e5b6f285bc43b342 /src/test/test_addr.c | |
parent | 2dbde3617f5d117e708dbd83410c8c73dc134902 (diff) | |
download | tor-60ce431c5440ee08e100a1f70a4d7224b7dc9c21.tar.gz tor-60ce431c5440ee08e100a1f70a4d7224b7dc9c21.zip |
test/addr: Add some ambiguous IPv6 cases to test_addr_parse()
Test some strings which could be parsed as IPv6 addresses,
or as IPv6:port strings.
Additional tests for 30721.
Diffstat (limited to 'src/test/test_addr.c')
-rw-r--r-- | src/test/test_addr.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test_addr.c b/src/test/test_addr.c index 6a6796c987..1b25c4c643 100644 --- a/src/test/test_addr.c +++ b/src/test/test_addr.c @@ -901,6 +901,23 @@ test_addr_parse(void *arg) /* IPv6 address with port and no brackets */ TEST_ADDR_PARSE_XFAIL_MALFORMED("11:22::33:44:12345"); + /* Is it a port, or are there too many hex words? + * We reject it either way. */ + TEST_ADDR_PARSE_XFAIL_MALFORMED("11:22:33:44:55:66:77:88:99"); + /* But we accept it if it has square brackets. */ + TEST_ADDR_V6_PORT_PARSE("[11:22:33:44:55:66:77:88]:99", + "11:22:33:44:55:66:77:88",99); + + /* This is an IPv6 address */ + TEST_ADDR_V6_PARSE_CANONICAL("11:22:33:44:55:66:77:88", 0); + TEST_ADDR_V6_PARSE_CANONICAL("[11:22:33:44:55:66:77:88]", 1); + + /* And this is an ambiguous case, which is interpreted as an IPv6 address. */ + TEST_ADDR_V6_PARSE_CANONICAL("11:22::88:99", 0); + /* Use square brackets to resolve the ambiguity */ + TEST_ADDR_V6_PARSE_CANONICAL("[11:22::88:99]", 1); + TEST_ADDR_V6_PORT_PARSE("[11:22::88]:99", + "11:22::88",99); /* Correct calls. */ TEST_ADDR_V4_PORT_PARSE("192.0.2.1:1234", "192.0.2.1", 1234); |