]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make tor_addr_is_internal log the calling function on error
authorNick Mathewson <nickm@torproject.org>
Fri, 12 Oct 2012 15:34:54 +0000 (11:34 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 12 Oct 2012 15:34:54 +0000 (11:34 -0400)
This might make it a little easier to track down bug  7086.

changes/addr_is_internal_debug [new file with mode: 0644]
src/common/address.c
src/common/address.h

diff --git a/changes/addr_is_internal_debug b/changes/addr_is_internal_debug
new file mode 100644 (file)
index 0000000..6de221b
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features:
+    - Log the call-site of a failed tor_addr_is_internal(), so that we
+      can learn who is calling it with AF_UNSPECIFIED and fix the
+      second (unrelated) part of bug 7086.
index 9a61872af3b7641dbd144e82a6b99a67b570b8aa..2c0c97db98514948186103ea71d1a1cb1751bb2b 100644 (file)
@@ -305,7 +305,8 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
  * also treated as internal for now.)
  */
 int
-tor_addr_is_internal(const tor_addr_t *addr, int for_listening)
+tor_addr_is_internal_(const tor_addr_t *addr, int for_listening,
+                      const char *filename, int lineno)
 {
   uint32_t iph4 = 0;
   uint32_t iph6[4];
@@ -355,8 +356,8 @@ tor_addr_is_internal(const tor_addr_t *addr, int for_listening)
 
   /* unknown address family... assume it's not safe for external use */
   /* rather than tor_assert(0) */
-  log_warn(LD_BUG, "tor_addr_is_internal() called with a non-IP address of "
-           "type %d", (int)v_family);
+  log_warn(LD_BUG, "tor_addr_is_internal() called from %s:%d with a "
+           "non-IP address of type %d", filename, lineno, (int)v_family);
   tor_fragile_assert();
   return 1;
 }
index 68775fb291072a60fad256374f08ec0eea3eabb4..9e7d7501262e8c6ffcfb2028bd9e1d02bdf88ba4 100644 (file)
@@ -168,7 +168,10 @@ int tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
 
 unsigned int tor_addr_hash(const tor_addr_t *addr);
 int tor_addr_is_v4(const tor_addr_t *addr);
-int tor_addr_is_internal(const tor_addr_t *ip, int for_listening);
+int tor_addr_is_internal_(const tor_addr_t *ip, int for_listening,
+                          const char *filename, int lineno);
+#define tor_addr_is_internal(addr, for_listening) \
+  tor_addr_is_internal_((addr), (for_listening), _SHORT_FILE_, __LINE__)
 
 /** Longest length that can be required for a reverse lookup name. */
 /* 32 nybbles, 32 dots, 8 characters of "ip6.arpa", 1 NUL: 73 characters. */