[or-cvs] r14082: Fix bug in earlier bugfix. Note stupidness of allowing NULL (in tor/trunk: . doc/spec src/or)

nickm at seul.org nickm at seul.org
Mon Mar 17 20:10:58 UTC 2008


Author: nickm
Date: 2008-03-17 16:10:57 -0400 (Mon, 17 Mar 2008)
New Revision: 14082

Modified:
   tor/trunk/
   tor/trunk/doc/spec/dir-spec.txt
   tor/trunk/src/or/policies.c
   tor/trunk/src/or/routerparse.c
Log:
 r18896 at catbus:  nickm | 2008-03-17 16:10:54 -0400
 Fix bug in earlier bugfix.  Note stupidness of allowing NULL policies at all.  Disallow empty exit policies in router descriptors.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r18896] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/doc/spec/dir-spec.txt
===================================================================
--- tor/trunk/doc/spec/dir-spec.txt	2008-03-17 17:21:22 UTC (rev 14081)
+++ tor/trunk/doc/spec/dir-spec.txt	2008-03-17 20:10:57 UTC (rev 14082)
@@ -466,11 +466,12 @@
 
        [Any number]
 
-       These lines describe an "exit policy": the rules that an OR follows when
-       deciding whether to allow a new stream to a given address.  The
-       'exitpattern' syntax is described below.  The rules are considered in
-       order; if no rule matches, the address will be accepted.  For clarity,
-       the last such entry SHOULD be accept *:* or reject *:*.
+       These lines describe an "exit policy": the rules that an OR follows
+       when deciding whether to allow a new stream to a given address.  The
+       'exitpattern' syntax is described below.  There MUST be at least one
+       such entry.  The rules are considered in order; if no rule matches,
+       the address will be accepted.  For clarity, the last such entry SHOULD
+       be accept *:* or reject *:*.
 
     "router-signature" NL Signature NL
 

Modified: tor/trunk/src/or/policies.c
===================================================================
--- tor/trunk/src/or/policies.c	2008-03-17 17:21:22 UTC (rev 14081)
+++ tor/trunk/src/or/policies.c	2008-03-17 20:10:57 UTC (rev 14082)
@@ -51,7 +51,7 @@
   int i;
   smartlist_t *tmp;
 
-  if (!*policy)
+  if (!*policy) /*XXXX021 disallow NULL policies */
     return;
 
   tmp = smartlist_create();
@@ -530,10 +530,8 @@
   int match = 0;
   int maybe = 0;
   int i, len;
-  if (!policy)
-    return ADDR_POLICY_REJECTED;
 
-  len = smartlist_len(policy);
+  len = policy ? smartlist_len(policy) : 0;
 
   for (i = 0; i < len; ++i) {
     addr_policy_t *tmpe = smartlist_get(policy, i);
@@ -767,7 +765,7 @@
   static const int ports[] = { 80, 443, 6667 };
   int n_allowed = 0;
   int i;
-  if (!policy)
+  if (!policy) /*XXXX021 disallow NULL policies */
     return 0;
 
   for (i = 0; i < 3; ++i) {
@@ -793,7 +791,7 @@
 int
 policy_is_reject_star(smartlist_t *policy)
 {
-  if (!policy)
+  if (!policy) /*XXXX021 disallow NULL policies */
     return 1;
   SMARTLIST_FOREACH(policy, addr_policy_t *, p, {
     if (p->policy_type == ADDR_POLICY_ACCEPT)

Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c	2008-03-17 17:21:22 UTC (rev 14081)
+++ tor/trunk/src/or/routerparse.c	2008-03-17 20:10:57 UTC (rev 14082)
@@ -1272,6 +1272,10 @@
   }
 
   exit_policy_tokens = find_all_exitpolicy(tokens);
+  if (!smartlist_len(exit_policy_tokens)) {
+    log_warn(LD_DIR, "No exit policy tokens in descriptor.");
+    goto err;
+  }
   SMARTLIST_FOREACH(exit_policy_tokens, directory_token_t *, t,
                     if (router_add_exit_policy(router,t)<0) {
                       log_warn(LD_DIR,"Error in exit policy");



More information about the tor-commits mailing list