[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add an extra prop330 test, and clarifying comments.



commit ebb826f4a15c90d480bb5384facc9d05e13505ab
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Mar 24 10:19:21 2021 -0400

    Add an extra prop330 test, and clarifying comments.
    
    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       |  2 ++
 src/test/test_dirauth_ports.c | 23 +++++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/app/config/config.c b/src/app/config/config.c
index 395da5e66a..547662300d 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -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);
diff --git a/src/test/test_dirauth_ports.c b/src/test/test_dirauth_ports.c
index de10c7006e..5dc0b0b631 100644
--- a/src/test/test_dirauth_ports.c
+++ b/src/test/test_dirauth_ports.c
@@ -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();



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits