[tor-commits] [tor/master] Check hostname before using it in send_resolved_hostname_cell()

nickm at torproject.org nickm at torproject.org
Fri Jan 4 02:37:54 UTC 2019


commit 16199a54a2b3f5ce94c6ca4248cbf44448ba95ae
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Dec 17 09:14:16 2018 -0500

    Check hostname before using it in send_resolved_hostname_cell()
    
    Also, turn an absent hostname into a BUG(), not a crash.
    
    Found by scan-build.
    
    Closes ticket 28879; bugfix on 0.1.2.7-alpha
---
 changes/ticket28879     | 5 +++++
 src/feature/relay/dns.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/changes/ticket28879 b/changes/ticket28879
new file mode 100644
index 000000000..126420f6c
--- /dev/null
+++ b/changes/ticket28879
@@ -0,0 +1,5 @@
+  o Minor bugfixes (correctness):
+    - Fix an unreached code-path where we checked the value of "hostname"
+      inside send_resolved_hostnam_cell(). Previously, we used it before
+      checking it; now we check it first. Fixes bug 28879; bugfix on
+      0.1.2.7-alpha.
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c
index bc507d47f..cc213ff8d 100644
--- a/src/feature/relay/dns.c
+++ b/src/feature/relay/dns.c
@@ -586,8 +586,11 @@ send_resolved_hostname_cell,(edge_connection_t *conn,
   char buf[RELAY_PAYLOAD_SIZE];
   size_t buflen;
   uint32_t ttl;
+
+  if (BUG(!hostname))
+    return;
+
   size_t namelen = strlen(hostname);
-  tor_assert(hostname);
 
   tor_assert(namelen < 256);
   ttl = dns_clip_ttl(conn->address_ttl);





More information about the tor-commits mailing list