]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Prevent changes to other options from removing . from AutomapHostsSuffixes
authorNick Mathewson <nickm@torproject.org>
Sun, 4 Jan 2015 22:28:54 +0000 (17:28 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 4 Jan 2015 22:28:54 +0000 (17:28 -0500)
This happened because we changed AutomapHostsSuffixes to replace "."
with "", since a suffix of "" means "match everything."  But our
option handling code for CSV options likes to remove empty entries
when it re-parses stuff.

Instead, let "." remain ".", and treat it specially when we're
checking for a match.

Fixes bug 12509; bugfix on 0.2.0.1-alpha.

changes/bug12509 [new file with mode: 0644]
src/or/addressmap.c
src/or/config.c
src/or/or.h

diff --git a/changes/bug12509 b/changes/bug12509
new file mode 100644 (file)
index 0000000..8d5c1dd
--- /dev/null
@@ -0,0 +1,4 @@
+
+  o Minor bugfixes (automapping):
+    - Prevent changes to other optoins from removing the wildcard value "."
+      from "AutomapHostsSuffixes".
index 998770a3db2d3d3d66b355a19efe241487648b4b..279132e97cb05fcfe642701ec0d91997950ce529 100644 (file)
@@ -226,6 +226,8 @@ addressmap_address_should_automap(const char *address,
     return 0;
 
   SMARTLIST_FOREACH_BEGIN(suffix_list, const char *, suffix) {
+    if (!strcmp(suffix, "."))
+      return 1;
     if (!strcasecmpend(address, suffix))
       return 1;
   } SMARTLIST_FOREACH_END(suffix);
index 892108278e0d990af1e93b5ca83a4e43ce91dab8..b047b12717688e46b63e28c9e97cfd3fa7e97eca 100644 (file)
@@ -3398,15 +3398,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
                                  AF_INET6, 1, msg)<0)
     return -1;
 
-  if (options->AutomapHostsSuffixes) {
-    SMARTLIST_FOREACH(options->AutomapHostsSuffixes, char *, suf,
-    {
-      size_t len = strlen(suf);
-      if (len && suf[len-1] == '.')
-        suf[len-1] = '\0';
-    });
-  }
-
   if (options->TestingTorNetwork &&
       !(options->DirAuthorities ||
         (options->AlternateDirAuthority &&
index 160958771796a7bae8b8e38517b5a51f19e056a1..66d10ac436fa62e6932705de2455895c0d9a8052 100644 (file)
@@ -3646,8 +3646,9 @@ typedef struct {
                               * hostname ending with one of the suffixes in
                               * <b>AutomapHostsSuffixes</b>, map it to a
                               * virtual address. */
-  smartlist_t *AutomapHostsSuffixes; /**< List of suffixes for
-                                      * <b>AutomapHostsOnResolve</b>. */
+  /** List of suffixes for <b>AutomapHostsOnResolve</b>.  The special value
+   * "." means "match everything." */
+  smartlist_t *AutomapHostsSuffixes;
   int RendPostPeriod; /**< How often do we post each rendezvous service
                        * descriptor? Remember to publish them independently. */
   int KeepalivePeriod; /**< How often do we send padding cells to keep