diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-06 09:47:32 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-06 09:47:32 -0400 |
commit | 8815960c4615da0015e78c3256c3f611a30f6e6c (patch) | |
tree | e6659be5abd68f92d88684f7904ea775a5bcf5a3 /src | |
parent | 6edee54afaaa60f34bed0dedb2792766f8683cd5 (diff) | |
parent | 326b510bae0b0d479dd924a233c6f6150737eb8b (diff) | |
download | tor-8815960c4615da0015e78c3256c3f611a30f6e6c.tar.gz tor-8815960c4615da0015e78c3256c3f611a30f6e6c.zip |
Merge remote-tracking branch 'tor-github/pr/294'
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/rend/rendservice.c | 8 | ||||
-rw-r--r-- | src/test/test_controller.c | 7 | ||||
-rw-r--r-- | src/test/test_hs_config.c | 14 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c index 66a4fb5f4f..37e604d07d 100644 --- a/src/feature/rend/rendservice.c +++ b/src/feature/rend/rendservice.c @@ -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; diff --git a/src/test/test_controller.c b/src/test/test_controller.c index d5d51758fb..0428ac6fce 100644 --- a/src/test/test_controller.c +++ b/src/test/test_controller.c @@ -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); diff --git a/src/test/test_hs_config.c b/src/test/test_hs_config.c index 498d2df197..553b96758a 100644 --- a/src/test/test_hs_config.c +++ b/src/test/test_hs_config.c @@ -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 = |