[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] test/addr: Add unit tests for the fixes in 30721
commit 1d3d6bf6b18ff7d3462d48d33d3e982f063f35d6
Author: teor <teor@xxxxxxxxxxxxxx>
Date: Thu Jun 13 21:22:27 2019 +1000
test/addr: Add unit tests for the fixes in 30721
---
src/test/test_addr.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index 05d8bf6c7..a961a4685 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -788,6 +788,10 @@ test_addr_parse(void *arg)
r= tor_addr_parse(&addr, "11:22:33:44:55:66:77:88:1.2.3.4");
tt_int_op(r,OP_EQ, -1);
+ /* IPv6 address with port and no brackets */
+ r= tor_addr_parse(&addr, "11:22::33:44:12345");
+ tt_int_op(r, OP_EQ, -1);
+
/* Correct call. */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.1:1234",
@@ -834,6 +838,18 @@ test_addr_parse(void *arg)
tt_int_op(r, OP_EQ, 0);
tt_int_op(port,OP_EQ,400);
+ /* Allow IPv6 without square brackets, when there is no port */
+ r= tor_addr_port_parse(LOG_DEBUG,
+ "::1",
+ &addr, &port, -1);
+ tt_int_op(r, OP_EQ, -1);
+
+ r= tor_addr_port_parse(LOG_DEBUG,
+ "::1",
+ &addr, &port, 600);
+ tt_int_op(r, OP_EQ, 0);
+ tt_int_op(port,OP_EQ,600);
+
/* Bad port. */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2:66666",
@@ -854,12 +870,29 @@ test_addr_parse(void *arg)
&addr, &port, 200);
tt_int_op(r, OP_EQ, -1);
- /* Bad IP address */
+ /* Bad IPv4 address */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2:1234",
&addr, &port, -1);
tt_int_op(r, OP_EQ, -1);
+ /* Bad IPv4 address and port: brackets */
+ r= tor_addr_port_parse(LOG_DEBUG,
+ "[192.0.2.3]:12345",
+ &addr, &port, -1);
+ tt_int_op(r, OP_EQ, -1);
+
+ /* Bad IPv6 addresses and ports: no brackets */
+ r= tor_addr_port_parse(LOG_DEBUG,
+ "::1:12345",
+ &addr, &port, -1);
+ tt_int_op(r, OP_EQ, -1);
+
+ r= tor_addr_port_parse(LOG_DEBUG,
+ "11:22::33:44:12345",
+ &addr, &port, -1);
+ tt_int_op(r, OP_EQ, -1);
+
/* Make sure that the default port has lower priority than the real
one */
r= tor_addr_port_parse(LOG_DEBUG,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits