mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Stricter HiddenServicePort parsing
This commit is contained in:
parent
103dd68ba8
commit
3890ad2578
4 changed files with 34 additions and 0 deletions
5
changes/bug27044
Normal file
5
changes/bug27044
Normal file
|
@ -0,0 +1,5 @@
|
|||
o Minor bugfixes (configuration, Onion Services):
|
||||
- In rend_service_parse_port_config(), disallow any input to
|
||||
remain after address-port pair was parsed. This will catch
|
||||
address and port being whitespace-separated by mistake of
|
||||
the user. Fixes bug 27044; bugfix on 0.2.9.10.
|
|
@ -451,11 +451,19 @@ rend_service_parse_port_config(const char *string, const char *sep,
|
|||
int is_unix;
|
||||
ret = port_cfg_line_extract_addrport(addrport_element, &addrport,
|
||||
&is_unix, &rest);
|
||||
|
||||
if (ret < 0) {
|
||||
tor_asprintf(&err_msg, "Couldn't process address <%s> from hidden "
|
||||
"service configuration", addrport_element);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (rest && strlen(rest)) {
|
||||
err_msg = tor_strdup("HiddenServicePort parse error: invalid port "
|
||||
"mapping");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (is_unix) {
|
||||
socket_path = addrport;
|
||||
is_unix_addr = 1;
|
||||
|
|
|
@ -346,6 +346,13 @@ test_rend_service_parse_port_config(void *arg)
|
|||
"in hidden service port configuration.");
|
||||
tor_free(err_msg);
|
||||
|
||||
/* Wrong target address and port separation */
|
||||
cfg = rend_service_parse_port_config("80,127.0.0.1 1234", sep,
|
||||
&err_msg);
|
||||
tt_ptr_op(cfg, OP_EQ, NULL);
|
||||
tt_assert(err_msg);
|
||||
tor_free(err_msg);
|
||||
|
||||
done:
|
||||
rend_service_port_config_free(cfg);
|
||||
tor_free(err_msg);
|
||||
|
|
|
@ -139,6 +139,20 @@ test_invalid_service(void *arg)
|
|||
teardown_capture_of_logs();
|
||||
}
|
||||
|
||||
/* Bad target addr:port separation. */
|
||||
{
|
||||
const char *conf =
|
||||
"HiddenServiceDir /tmp/tor-test-hs-RANDOM/hs1\n"
|
||||
"HiddenServiceVersion 2\n"
|
||||
"HiddenServicePort 80 127.0.0.1 8000\n";
|
||||
setup_full_capture_of_logs(LOG_WARN);
|
||||
ret = helper_config_service(conf, 1);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
expect_log_msg_containing("HiddenServicePort parse error: "
|
||||
"invalid port mapping");
|
||||
teardown_capture_of_logs();
|
||||
}
|
||||
|
||||
/* Out of order directives. */
|
||||
{
|
||||
const char *conf =
|
||||
|
|
Loading…
Add table
Reference in a new issue