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

[or-cvs] r8438: Fix a bug: Remember, each call to escaped() replaces the val (in tor/trunk: . src/or)



Author: nickm
Date: 2006-09-21 17:48:11 -0400 (Thu, 21 Sep 2006)
New Revision: 8438

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/config.c
   tor/trunk/src/or/dns.c
Log:
 r8873@Kushana:  nickm | 2006-09-21 14:38:22 -0400
 Fix a bug: Remember, each call to escaped() replaces the value returned from the last call to escaped().



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/branches/eventdns [r8873] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-09-21 21:48:06 UTC (rev 8437)
+++ tor/trunk/ChangeLog	2006-09-21 21:48:11 UTC (rev 8438)
@@ -19,6 +19,8 @@
       algorithm from O(n^2) to O(n).
     - Make the common memory allocation path faster on machines where
       malloc(0) returns a pointer.
+    - Fix a debug log message in eventdns to say "X resolved to Y"
+      instead of "X resolved to X".
 
 Changes in version 0.1.2.1-alpha - 2006-08-27
   o Major features:

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-09-21 21:48:06 UTC (rev 8437)
+++ tor/trunk/src/or/config.c	2006-09-21 21:48:11 UTC (rev 8438)
@@ -520,7 +520,9 @@
     return address;
 }
 
-/** Equivalent to escaped(safe_str(address)) */
+/** Equivalent to escaped(safe_str(address)).  See reentrancy node on
+ * escaped(): don't use this outside the main thread, or twice in the same
+ * log statement. */
 const char *
 escaped_safe_str(const char *address)
 {

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-09-21 21:48:06 UTC (rev 8437)
+++ tor/trunk/src/or/dns.c	2006-09-21 21:48:11 UTC (rev 8438)
@@ -1464,20 +1464,26 @@
     if (type == DNS_IPv4_A && count) {
       char answer_buf[INET_NTOA_BUF_LEN+1];
       struct in_addr in;
+      char *escaped_address;
       uint32_t *addrs = addresses;
       in.s_addr = addrs[0];
       addr = ntohl(addrs[0]);
       status = DNS_RESOLVE_SUCCEEDED;
       tor_inet_ntoa(&in, answer_buf, sizeof(answer_buf));
+      escaped_address = esc_for_log(string_address);
       log_debug(LD_EXIT, "eventdns said that %s resolves to %s",
-                escaped_safe_str(string_address),
-                escaped_safe_str(answer_buf)); // XXXX not ok.
+                safe_str(escaped_address),
+                escaped_safe_str(answer_buf));
+      tor_free(escaped_address);
     } else if (type == DNS_PTR && count) {
+      char *escaped_address;
       is_reverse = 1;
       hostname = ((char**)addresses)[0];
+      escaped_address = esc_for_log(string_address);
       log_debug(LD_EXIT, "eventdns said that %s resolves to %s",
-                escaped_safe_str(string_address),
-                escaped_safe_str(hostname)); // XXXX not ok.
+                safe_str(escaped_address),
+                escaped_safe_str(hostname));
+      tor_free(escaped_address);
     } else if (count) {
       log_warn(LD_EXIT, "eventdns returned only non-IPv4 answers for %s.",
                escaped_safe_str(string_address));