]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check IPv6 exit policies on microdescriptors in node_exit_policy_rejects_all()
authorNeel Chauhan <neel@neelc.org>
Mon, 26 Aug 2019 00:22:57 +0000 (20:22 -0400)
committerGeorge Kadianakis <desnacked@riseup.net>
Thu, 5 Sep 2019 14:02:45 +0000 (17:02 +0300)
changes/bug27284 [new file with mode: 0644]
src/feature/dirparse/microdesc_parse.c
src/feature/nodelist/microdesc_st.h
src/feature/nodelist/nodelist.c

diff --git a/changes/bug27284 b/changes/bug27284
new file mode 100644 (file)
index 0000000..14fc208
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes (ipv6):
+    - When parsing microdescriptors, we should check the IPv6 exit policy
+      alongside IPv4. Previously, we checked both exit policies for only
+      router info structures, while microdescriptors were IPv4-only. Fixes
+      bug 27284; bugfix on 0.2.3.1-alpha. Patch by Neel Chauhan.
index 22cc1e272edc801752ee3af6d8e5dbb3e0e48a8c..e02dfcf11ae4186b7a9cef1dbca5585fae1ead2e 100644 (file)
@@ -92,6 +92,12 @@ find_start_of_next_microdesc(const char *s, const char *eos)
 #undef NEXT_LINE
 }
 
+static inline int
+policy_is_reject_star_or_null(struct short_policy_t *policy)
+{
+  return !policy || short_policy_is_reject_star(policy);
+}
+
 /** Parse as many microdescriptors as are found from the string starting at
  * <b>s</b> and ending at <b>eos</b>.  If allow_annotations is set, read any
  * annotations we recognize and ignore ones we don't.
@@ -250,6 +256,11 @@ microdescs_parse_from_string(const char *s, const char *eos,
       md->ipv6_exit_policy = parse_short_policy(tok->args[0]);
     }
 
+    if (policy_is_reject_star_or_null(md->exit_policy) &&
+        policy_is_reject_star_or_null(md->ipv6_exit_policy)) {
+      md->policy_is_reject_star = 1;
+    }
+
     smartlist_add(result, md);
     okay = 1;
 
index c8265cb778768ab27729e2bb3228a7f9d017b3a4..e017c46c793f98cbae71d5662ba7c27b7a98675d 100644 (file)
@@ -33,6 +33,8 @@ struct microdesc_t {
   unsigned int no_save : 1;
   /** If true, this microdesc has an entry in the microdesc_map */
   unsigned int held_in_map : 1;
+  /** True iff the exit policy for this router rejects everything. */
+  unsigned int policy_is_reject_star : 1;
   /** Reference count: how many node_ts have a reference to this microdesc? */
   unsigned int held_by_nodes;
 
index 21914c6c6df34517b3a4732b5b15af9d75ddf640..6ae8d2bcb14b7f51ac300a20ff08dd4be4ab83fe 100644 (file)
@@ -1424,8 +1424,7 @@ node_exit_policy_rejects_all(const node_t *node)
   if (node->ri)
     return node->ri->policy_is_reject_star;
   else if (node->md)
-    return node->md->exit_policy == NULL ||
-      short_policy_is_reject_star(node->md->exit_policy);
+    return node->md->policy_is_reject_star;
   else
     return 1;
 }