mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
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.
This commit is contained in:
parent
db14801b04
commit
ebb826f4a1
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user