]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check hostname before using it in send_resolved_hostname_cell()
authorNick Mathewson <nickm@torproject.org>
Mon, 17 Dec 2018 14:14:16 +0000 (09:14 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 17 Dec 2018 14:15:37 +0000 (09:15 -0500)
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 [new file with mode: 0644]
src/feature/relay/dns.c

diff --git a/changes/ticket28879 b/changes/ticket28879
new file mode 100644 (file)
index 0000000..126420f
--- /dev/null
@@ -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.
index bc507d47f629df4e915fc984e022d79454497a41..cc213ff8d6527e36abd8d0ad4d9aac798798e1b9 100644 (file)
@@ -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);