diff options
author | Nick Mathewson <nickm@torproject.org> | 2021-03-24 10:19:21 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2021-03-24 10:31:13 -0400 |
commit | ebb826f4a15c90d480bb5384facc9d05e13505ab (patch) | |
tree | 891ca04dfaf7ad0e588809c3c4a9e3013b93386c /src/test/test_dirauth_ports.c | |
parent | db14801b04dc27760c71ff6567c59c222459bfe6 (diff) | |
download | tor-ebb826f4a15c90d480bb5384facc9d05e13505ab.tar.gz tor-ebb826f4a15c90d480bb5384facc9d05e13505ab.zip |
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.
Diffstat (limited to 'src/test/test_dirauth_ports.c')
-rw-r--r-- | src/test/test_dirauth_ports.c | 23 |
1 files changed, 21 insertions, 2 deletions
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(); |