]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Reject attempts to say FooPort and FooPort 0 in the same cfg domain
authorNick Mathewson <nickm@torproject.org>
Thu, 9 Aug 2012 20:13:03 +0000 (16:13 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 9 Aug 2012 20:13:03 +0000 (16:13 -0400)
changes/bug6507
src/or/config.c

index 5ca02984bd8e1e3604321ad01c3e4f6512f862ed..89940cbf7ba07b97a667b8f65a7280bc5d630bad 100644 (file)
@@ -5,3 +5,11 @@
       server, even though our new listener code would correctly not
       open any ORPorts for ORPort 0. Similar bugs in other Port
       options are also fixed. Fixes bug 6507; bugfix on 0.2.3.3-alpha.
+
+  o Minor features:
+
+    - Detect and reject attempts to specify both 'FooPort' and
+      'FooPort 0' in the same configuration domain.  (It's still okay
+      to have a FooPort in your configuration file,and use 'FooPort 0'
+      on the command line to disable it.) Fixes another case of
+      bug6507; bugfix on 0.2.3.3-alpha.
index 6163599358f9d5ae63f4c14480aa09b252c73101..639abcdb4778298e634bd81e0956d1a81e70d009 100644 (file)
@@ -5667,6 +5667,7 @@ parse_port_config(smartlist_t *out,
   const unsigned forbid_nonlocal = flags & CL_PORT_FORBID_NONLOCAL;
   const unsigned allow_spurious_listenaddr =
     flags & CL_PORT_ALLOW_EXTRA_LISTENADDR;
+  int got_zero_port=0, got_nonzero_port=0;
 
   /* FooListenAddress is deprecated; let's make it work like it used to work,
    * though. */
@@ -5919,6 +5920,11 @@ parse_port_config(smartlist_t *out,
       } SMARTLIST_FOREACH_END(elt);
     }
 
+    if (port)
+      got_nonzero_port = 1;
+    else
+      got_zero_port = 1;
+
     if (out && port) {
       port_cfg_t *cfg = tor_malloc_zero(sizeof(port_cfg_t));
       tor_addr_copy(&cfg->addr, &addr);
@@ -5945,6 +5951,13 @@ parse_port_config(smartlist_t *out,
       warn_nonlocal_client_ports(out, portname);
   }
 
+  if (got_zero_port && got_nonzero_port) {
+    log_warn(LD_CONFIG, "You specified a nonzero %sPort along with '%sPort 0' "
+             "in the same configuration. Did you mean to disable %sPort or "
+             "not?", portname, portname, portname);
+    goto err;
+  }
+
   retval = 0;
  err:
   SMARTLIST_FOREACH(elts, char *, cp, tor_free(cp));