[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Fix assertion to actually have a chance of failing



commit 0e348720fc3a4db0e61fcb81673080ae71e80b4e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon May 15 11:25:52 2017 -0400

    Fix assertion to actually have a chance of failing
    
    This assertion can only fail if we mess up some of our other code,
    but let's try to get it right.
    
    Closes 22244.
---
 changes/bug22244 | 6 ++++++
 src/or/dns.c     | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/changes/bug22244 b/changes/bug22244
new file mode 100644
index 0000000..ed5d36b
--- /dev/null
+++ b/changes/bug22244
@@ -0,0 +1,6 @@
+  o Minor bugfixes (exit-side DNS):
+    - Fix an untriggerable assertion that checked the output of a
+      libevent DNS error, so that the assertion actually behaves as
+      expected.  Fixes bug 22244; bugfix on 0.2.0.20-rc. Found by Andrey
+      Karpov using PVS-Studio.
+
diff --git a/src/or/dns.c b/src/or/dns.c
index cd84a64..024a21a 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -160,8 +160,9 @@ evdns_log_cb(int warn, const char *msg)
   }
   if (!strcmpstart(msg, "Nameserver ") && (cp=strstr(msg, " has failed: "))) {
     char *ns = tor_strndup(msg+11, cp-(msg+11));
-    const char *err = strchr(cp, ':')+2;
-    tor_assert(err);
+    const char *colon = strchr(cp, ':');
+    tor_assert(colon);
+    const char *err = colon+2;
     /* Don't warn about a single failed nameserver; we'll warn with 'all
      * nameservers have failed' if we're completely out of nameservers;
      * otherwise, the situation is tolerable. */

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits