]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Detect tor_addr_to_str failure in tor_dup_addr.
authorNick Mathewson <nickm@torproject.org>
Thu, 24 Nov 2011 04:04:10 +0000 (23:04 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 24 Nov 2011 04:04:10 +0000 (23:04 -0500)
This avoids a possible strdup of an uninitialized buffer.

Fixes 4529; fix on 0.2.1.3-alpha; reported by troll_un.

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

diff --git a/changes/bug4529 b/changes/bug4529
new file mode 100644 (file)
index 0000000..89d10b2
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bufixes:
+    - If we had ever tried to call tor_addr_to_str on an address of
+      unknown type, we would have done a strdup on an uninitialized
+      buffer. Now we won't. Fixes bug 4529; bugfix on 0.2.1.3-alpha.
+      Reported by "troll_un".
index 7fc730105146e3470d0995cd8fa6d49b799965e1..46ccb1fe4aaee1099f5594e459da6b2d550e3050 100644 (file)
@@ -945,8 +945,11 @@ char *
 tor_dup_addr(const tor_addr_t *addr)
 {
   char buf[TOR_ADDR_BUF_LEN];
-  tor_addr_to_str(buf, addr, sizeof(buf), 0);
-  return tor_strdup(buf);
+  if (tor_addr_to_str(buf, addr, sizeof(buf), 0)) {
+    return tor_strdup(buf);
+  } else {
+    return tor_strdup("<unknown address type>");
+  }
 }
 
 /** Return a string representing the address <b>addr</b>.  This string is