aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug213293
-rw-r--r--configure.ac2
-rw-r--r--contrib/win32build/tor-mingw.nsi.in2
-rw-r--r--src/or/control.c13
-rw-r--r--src/or/control.h5
-rw-r--r--src/test/test_controller.c40
-rw-r--r--src/win32/orconfig.h2
7 files changed, 58 insertions, 9 deletions
diff --git a/changes/bug21329 b/changes/bug21329
new file mode 100644
index 0000000000..60b936393e
--- /dev/null
+++ b/changes/bug21329
@@ -0,0 +1,3 @@
+ o Minor bugfixes (controller):
+ - GETINFO onions/current and onions/detached no longer 551 on empty lists
+ Fixes bug 21329
diff --git a/configure.ac b/configure.ac
index c9e0c2a4ba..59da60c6c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl Copyright (c) 2007-2015, The Tor Project, Inc.
dnl See LICENSE for licensing information
AC_PREREQ([2.63])
-AC_INIT([tor],[0.3.0.3-alpha-dev])
+AC_INIT([tor],[0.3.1.0-alpha-dev])
AC_CONFIG_SRCDIR([src/or/main.c])
AC_CONFIG_MACRO_DIR([m4])
diff --git a/contrib/win32build/tor-mingw.nsi.in b/contrib/win32build/tor-mingw.nsi.in
index 62e80360d5..c63f838f1e 100644
--- a/contrib/win32build/tor-mingw.nsi.in
+++ b/contrib/win32build/tor-mingw.nsi.in
@@ -8,7 +8,7 @@
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
-!define VERSION "0.3.0.3-alpha-dev"
+!define VERSION "0.3.1.0-alpha-dev"
!define INSTALLER "tor-${VERSION}-win32.exe"
!define WEBSITE "https://www.torproject.org/"
!define LICENSE "LICENSE"
diff --git a/src/or/control.c b/src/or/control.c
index b0a687679d..8ab31f18f7 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2824,12 +2824,13 @@ getinfo_helper_events(control_connection_t *control_conn,
/** Implementation helper for GETINFO: knows how to enumerate hidden services
* created via the control port. */
-static int
+STATIC int
getinfo_helper_onions(control_connection_t *control_conn,
const char *question, char **answer,
const char **errmsg)
{
smartlist_t *onion_list = NULL;
+ (void) errmsg; /* no errors from this method */
if (control_conn && !strcmp(question, "onions/current")) {
onion_list = control_conn->ephemeral_onion_services;
@@ -2839,13 +2840,13 @@ getinfo_helper_onions(control_connection_t *control_conn,
return 0;
}
if (!onion_list || smartlist_len(onion_list) == 0) {
- if (errmsg) {
- *errmsg = "No onion services of the specified type.";
+ if (answer) {
+ *answer = tor_strdup("");
}
- return -1;
- }
- if (answer) {
+ } else {
+ if (answer) {
*answer = smartlist_join_strings(onion_list, "\r\n", 0, NULL);
+ }
}
return 0;
diff --git a/src/or/control.h b/src/or/control.h
index 6330c85571..16ba1ed8f0 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -262,6 +262,11 @@ STATIC crypto_pk_t *add_onion_helper_keyarg(const char *arg, int discard_pk,
STATIC rend_authorized_client_t *
add_onion_helper_clientauth(const char *arg, int *created, char **err_msg_out);
+STATIC int getinfo_helper_onions(
+ control_connection_t *control_conn,
+ const char *question,
+ char **answer,
+ const char **errmsg);
STATIC void getinfo_helper_downloads_networkstatus(
const char *flavor,
download_status_t **dl_to_emit,
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index d9c0a1eaac..206315e289 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -109,6 +109,45 @@ test_add_onion_helper_keyarg(void *arg)
}
static void
+test_getinfo_helper_onion(void *arg)
+{
+ (void)arg;
+ control_connection_t dummy;
+ /* Get results out */
+ char *answer = NULL;
+ const char *errmsg = NULL;
+ char *service_id = NULL;
+ int rt = 0;
+
+ dummy.ephemeral_onion_services = NULL;
+
+ /* successfully get an empty answer */
+ rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg);
+ tt_assert(rt == 0);
+ tt_str_op(answer, OP_EQ, "");
+ tor_free(answer);
+
+ /* successfully get an empty answer */
+ rt = getinfo_helper_onions(&dummy, "onions/detached", &answer, &errmsg);
+ tt_assert(rt == 0);
+ tt_str_op(answer, OP_EQ, "");
+ tor_free(answer);
+
+ /* get an answer for one onion service */
+ service_id = tor_strdup("dummy_onion_id");
+ dummy.ephemeral_onion_services = smartlist_new();
+ smartlist_add(dummy.ephemeral_onion_services, service_id);
+ rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg);
+ tt_assert(rt == 0);
+ tt_str_op(answer, OP_EQ, "dummy_onion_id");
+
+ done:
+ tor_free(answer);
+ tor_free(service_id);
+ smartlist_free(dummy.ephemeral_onion_services);
+}
+
+static void
test_rend_service_parse_port_config(void *arg)
{
const char *sep = ",";
@@ -1332,6 +1371,7 @@ test_download_status_bridge(void *arg)
struct testcase_t controller_tests[] = {
{ "add_onion_helper_keyarg", test_add_onion_helper_keyarg, 0, NULL, NULL },
+ { "getinfo_helper_onion", test_getinfo_helper_onion, 0, NULL, NULL },
{ "rend_service_parse_port_config", test_rend_service_parse_port_config, 0,
NULL, NULL },
{ "add_onion_helper_clientauth", test_add_onion_helper_clientauth, 0, NULL,
diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h
index ec4d62b8c2..f7f4f19505 100644
--- a/src/win32/orconfig.h
+++ b/src/win32/orconfig.h
@@ -218,7 +218,7 @@
#define USING_TWOS_COMPLEMENT
/* Version number of package */
-#define VERSION "0.3.0.3-alpha-dev"
+#define VERSION "0.3.1.0-alpha-dev"