]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check for NULL values in getinfo_helper_onions
authorteor <teor2345@gmail.com>
Tue, 2 Jun 2015 17:58:28 +0000 (03:58 +1000)
committerteor <teor2345@gmail.com>
Tue, 2 Jun 2015 18:19:06 +0000 (04:19 +1000)
Fix on 915c7438a77e in Tor 0.2.7.1-alpha.

changes/bug16115-NULL-getinfo-onions [new file with mode: 0644]
src/or/control.c

diff --git a/changes/bug16115-NULL-getinfo-onions b/changes/bug16115-NULL-getinfo-onions
new file mode 100644 (file)
index 0000000..ec1661e
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor fixes (threads, comments):
+    - Check for NULL values in getinfo_helper_onions
+      Patch by "teor".
+      Fix on 915c7438a77e in Tor 0.2.7.1-alpha.
index 2eaad4e373a661e3cf7d35b59152b843dc41cdcd..7a113f2c1cb92dd8e2e43a1b7f108a222fa8ee59 100644 (file)
@@ -2193,7 +2193,7 @@ getinfo_helper_onions(control_connection_t *control_conn,
 {
   smartlist_t *onion_list = NULL;
 
-  if (!strcmp(question, "onions/current")) {
+  if (control_conn && !strcmp(question, "onions/current")) {
     onion_list = control_conn->ephemeral_onion_services;
   } else if (!strcmp(question, "onions/detached")) {
     onion_list = detached_onion_services;
@@ -2201,10 +2201,14 @@ getinfo_helper_onions(control_connection_t *control_conn,
     return 0;
   }
   if (!onion_list || smartlist_len(onion_list) == 0) {
-    *errmsg = "No onion services of the specified type.";
+    if (errmsg) {
+        *errmsg = "No onion services of the specified type.";
+    }
     return -1;
   }
-  *answer = smartlist_join_strings(onion_list, "\r\n", 0, NULL);
+  if (answer) {
+      *answer = smartlist_join_strings(onion_list, "\r\n", 0, NULL);
+  }
 
   return 0;
 }