]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check return value in fmt_addr
authorNick Mathewson <nickm@torproject.org>
Wed, 20 Jul 2011 17:16:06 +0000 (13:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 20 Jul 2011 17:17:48 +0000 (13:17 -0400)
Previously, if tor_addr_to_str() returned NULL, we would reuse the
last value returned by fmt_addr().  (This could happen if we were
erroneously asked to format an AF_UNSPEC address.)  Now instead we
return "???".

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

diff --git a/changes/fmt_addr b/changes/fmt_addr
new file mode 100644 (file)
index 0000000..b88c9e1
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - When unable to format an address as a string, report its value
+      as "???" rather than reusing the last formatted address. Bugfix
+      on 0.2.1.5-alpha.
index 1c725393d964d65beebeff949886bb431a454d15..7fc730105146e3470d0995cd8fa6d49b799965e1 100644 (file)
@@ -958,8 +958,10 @@ fmt_addr(const tor_addr_t *addr)
 {
   static char buf[TOR_ADDR_BUF_LEN];
   if (!addr) return "<null>";
-  tor_addr_to_str(buf, addr, sizeof(buf), 0);
-  return buf;
+  if (tor_addr_to_str(buf, addr, sizeof(buf), 0))
+    return buf;
+  else
+    return "???";
 }
 
 /** Convert the string in <b>src</b> to a tor_addr_t <b>addr</b>.  The string