]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add an extra prop330 test, and clarifying comments.
authorNick Mathewson <nickm@torproject.org>
Wed, 24 Mar 2021 14:19:21 +0000 (10:19 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 24 Mar 2021 14:31:13 +0000 (10:31 -0400)
This test makes sure that we reject "upload=" URLs with bad IP
addresses.

Also, add a warning when we can't parse the address.

src/app/config/config.c
src/test/test_dirauth_ports.c

index 395da5e66a25ef56eeaf6fd882ba42bf52b2be80..547662300d7f6bd1e027b82c9467b5e1e447bd61 100644 (file)
@@ -5500,6 +5500,8 @@ parse_dirauth_dirport(dir_server_t *ds, const char *flag)
                                &dirport.addr, &dirport.port, -1);
   if (ds != NULL && rv == 0) {
     trusted_dir_server_add_dirport(ds, usage, &dirport);
+  } else if (rv == -1) {
+    log_warn(LD_CONFIG, "Unable to parse address in authority flag %s",flag);
   }
 
   tor_free(addr_string);
index de10c7006e8bf7f72a19b17f10b544e197e66004..5dc0b0b6311bac65f27638c06b1adf8f30434e62 100644 (file)
@@ -44,7 +44,7 @@ test_dirauth_port_parsing(void *arg)
   rv = parse_dir_authority_line(
     "moria1 orport=9101 "
     "v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 "
-    "upload=https://128.31.0.39:9131/ " // not recognized
+    "upload=https://128.31.0.39:9131/ " // https is not recognized
     "128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31",
     NO_DIRINFO, 1);
   tt_int_op(rv,OP_EQ,-1);
@@ -54,11 +54,30 @@ test_dirauth_port_parsing(void *arg)
   rv = parse_dir_authority_line(
     "moria1 orport=9101 "
     "v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 "
-    "upload=http://128.31.0.39:9131/tor " // not supported
+    "upload=http://128.31.0.39:9131/tor " // suffix is not supported
     "128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31",
     NO_DIRINFO, 1);
   tt_int_op(rv,OP_EQ,-1);
   expect_log_msg_containing("Unsupported URL prefix");
+  mock_clean_saved_logs();
+
+  rv = parse_dir_authority_line(
+    "moria1 orport=9101 "
+    "v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 "
+    "upload=http://128.31.0.256:9131/ " // "256" is not ipv4.
+    "128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31",
+    NO_DIRINFO, 1);
+  tt_int_op(rv,OP_EQ,-1);
+  expect_log_msg_containing("Unable to parse address");
+
+  rv = parse_dir_authority_line(
+    "moria1 orport=9101 "
+    "v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 "
+    "upload=http://xyz.example.com/ " // hostnames not supported.
+    "128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31",
+    NO_DIRINFO, 1);
+  tt_int_op(rv,OP_EQ,-1);
+  expect_log_msg_containing("Unable to parse address");
 
  done:
   teardown_capture_of_logs();