]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Routerset config parsing: represent empty sets as NULL.
authorNick Mathewson <nickm@torproject.org>
Wed, 28 Aug 2019 15:51:16 +0000 (11:51 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 28 Aug 2019 15:53:28 +0000 (11:53 -0400)
routerset_t has two representations of an empty routerset: NULL, and
a set containing no elements.  But some of our config code assumes
that empty routersets are represented as NULL.  So let's give it
what it assumes.

Fixes bug 31495. Bugfix on e16b90b88a76; but not in any released
Tor.

src/feature/nodelist/routerset.c

index 76777847efc2addb80c1b0639803ad690eece02c..12965ad0d8c8f376fbce0d198a70a6cab6b5c17a 100644 (file)
@@ -479,6 +479,10 @@ routerset_kv_parse(void *target, const config_line_t *line, char **errmsg,
     *errmsg = tor_strdup("Invalid router list.");
     return -1;
   } else {
+    if (routerset_is_empty(rs)) {
+      /* Represent empty sets as NULL. */
+      routerset_free(rs);
+    }
     *p = rs;
     return 0;
   }
@@ -507,8 +511,10 @@ routerset_copy(void *dest, const void *src, const void *params)
   routerset_t **output = (routerset_t**)dest;
   const routerset_t *input = *(routerset_t**)src;
   routerset_free(*output); // sets *output to NULL
-  *output = routerset_new();
-  routerset_union(*output, input);
+  if (! routerset_is_empty(input)) {
+    *output = routerset_new();
+    routerset_union(*output, input);
+  }
   return 0;
 }