]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Also test bracket-less IPv6 string validation
authorrl1987 <rl1987@sdf.lonestar.org>
Mon, 12 Feb 2018 20:16:38 +0000 (21:16 +0100)
committerNick Mathewson <nickm@torproject.org>
Wed, 28 Mar 2018 11:39:03 +0000 (07:39 -0400)
src/test/test_socks.c

index 3f9cc887b690c88cc70dc9c99e36c2f8ac7b7483..8da7191e826c6116412b2eac7d05f12620ccf65b 100644 (file)
@@ -365,6 +365,23 @@ test_socks_5_supported_commands(void *ptr)
 
   socks_request_clear(socks);
 
+  /* Also allow bracket-less form. */
+
+  ADD_DATA(buf, "\x05\x01\x00");
+  ADD_DATA(buf, "\x05\xF0\x00\x03\x27");
+  ADD_DATA(buf, "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
+  ADD_DATA(buf, "\x01\x02");
+  tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),
+            OP_EQ, 1);
+
+  tt_str_op("2001:0db8:85a3:0000:0000:8a2e:0370:7334", OP_EQ,
+    socks->address);
+  tt_int_op(258, OP_EQ, socks->port);
+
+  tt_int_op(0, OP_EQ, buf_datalen(buf));
+
+  socks_request_clear(socks);
+
   /* SOCKS 5 Send RESOLVE_PTR [F1] for IP address 2.2.2.5 */
   ADD_DATA(buf, "\x05\x01\x00");
   ADD_DATA(buf, "\x05\xF1\x00\x01\x02\x02\x02\x05\x01\x03");