[tor-commits] [tor/master] Return value bugfix of tor_addr_to_PTR_name

nickm at torproject.org nickm at torproject.org
Mon Nov 14 17:52:18 UTC 2011


commit 1b97588a31565269476a2537d93eae2a5919d9be
Author: Anders Sundman <anders at 4zm.org>
Date:   Fri Nov 11 08:04:05 2011 +0100

    Return value bugfix of tor_addr_to_PTR_name
    
    Returns value semantics was inconsitent between IPv4 and IPv6
---
 src/common/address.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/common/address.c b/src/common/address.c
index b41456f..06e4a1d 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -470,13 +470,17 @@ tor_addr_parse_PTR_name(tor_addr_t *result, const char *address,
   return 0;
 }
 
-/** Convert <b>addr</b> to an in-addr.arpa name or a .ip6.arpa name, and store
- * the result in the <b>outlen</b>-byte buffer at <b>out</b>.  Return 0 on
- * success, -1 on failure. */
+/** Convert <b>addr</b> to an in-addr.arpa name or a .ip6.arpa name,
+ * and store the result in the <b>outlen</b>-byte buffer at
+ * <b>out</b>.  Return the number of chars written to <b>out</b>, not
+ * including the trailing \0, on success. Returns -1 on failure. */
 int
 tor_addr_to_PTR_name(char *out, size_t outlen,
-                                const tor_addr_t *addr)
+                     const tor_addr_t *addr)
 {
+  tor_assert(out);
+  tor_assert(addr);
+
   if (addr->family == AF_INET) {
     uint32_t a = tor_addr_to_ipv4h(addr);
 
@@ -499,7 +503,7 @@ tor_addr_to_PTR_name(char *out, size_t outlen,
       *cp++ = '.';
     }
     memcpy(cp, "ip6.arpa", 9); /* 8 characters plus NUL */
-    return 0;
+    return 32 * 2 + 8;
   }
   return -1;
 }





More information about the tor-commits mailing list