[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] config: Make parse_outbound_addresses() return failures



commit 651629cbdf5ae1af6702d282516bebc124f8742a
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Thu Aug 31 08:29:09 2017 -0400

    config: Make parse_outbound_addresses() return failures
    
    The function was never returning an error code on failure to parse the
    OutboundAddress* options.
    
    In the process, it was making our test_options_validate__outbound_addresses()
    not test the right thing.
    
    Fixes #23366
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 changes/bug23366        |  4 ++++
 src/or/config.c         | 27 +++++++++++++++++++++------
 src/test/test_options.c |  2 ++
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/changes/bug23366 b/changes/bug23366
new file mode 100644
index 000000000..85e370f61
--- /dev/null
+++ b/changes/bug23366
@@ -0,0 +1,4 @@
+  o Minor bugfixes (test):
+    - Fix a broken OutboundAddress option unit test because the parsing
+      function was never returning an error on failure. Fixes bug #23366.;
+      bugfix on tor-0.3.0.3-alpha.
diff --git a/src/or/config.c b/src/or/config.c
index 30853724e..ff70a4465 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -7921,13 +7921,28 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg)
     memset(&options->OutboundBindAddresses, 0,
            sizeof(options->OutboundBindAddresses));
   }
-  parse_outbound_address_lines(options->OutboundBindAddress,
-                      OUTBOUND_ADDR_EXIT_AND_OR, options, validate_only, msg);
-  parse_outbound_address_lines(options->OutboundBindAddressOR,
-                      OUTBOUND_ADDR_OR, options, validate_only, msg);
-  parse_outbound_address_lines(options->OutboundBindAddressExit,
-                      OUTBOUND_ADDR_EXIT, options, validate_only, msg);
+
+  if (parse_outbound_address_lines(options->OutboundBindAddress,
+                                   OUTBOUND_ADDR_EXIT_AND_OR, options,
+                                   validate_only, msg) < 0) {
+    goto err;
+  }
+
+  if (parse_outbound_address_lines(options->OutboundBindAddressOR,
+                                   OUTBOUND_ADDR_OR, options, validate_only,
+                                   msg) < 0) {
+    goto err;
+  }
+
+  if (parse_outbound_address_lines(options->OutboundBindAddressExit,
+                                   OUTBOUND_ADDR_EXIT, options, validate_only,
+                                   msg)  < 0) {
+    goto err;
+  }
+
   return 0;
+ err:
+  return -1;
 }
 
 /** Load one of the geoip files, <a>family</a> determining which
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 5f35c47f7..92e698282 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -528,6 +528,8 @@ test_options_validate__outbound_addresses(void *ignored)
 
   ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg);
   tt_int_op(ret, OP_EQ, -1);
+  tt_str_op(msg, OP_EQ, "Multiple outbound bind addresses configured: "
+                        "xxyy!!!sdfaf");
 
  done:
   free_options_test_data(tdata);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits