diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-07-20 13:16:06 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-07-20 13:17:48 -0400 |
commit | 718252b253049f84fefa14e212cf560838e6607c (patch) | |
tree | 03443d167ced3ba3097554fd9b4785acd15aa9ce /src/common/address.c | |
parent | 3e3aac5fd552b7b1949b0d2e12368cea26449b83 (diff) | |
download | tor-718252b253049f84fefa14e212cf560838e6607c.tar.gz tor-718252b253049f84fefa14e212cf560838e6607c.zip |
Check return value in fmt_addr
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 "???".
Diffstat (limited to 'src/common/address.c')
-rw-r--r-- | src/common/address.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/address.c b/src/common/address.c index 1c725393d9..7fc7301051 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -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 |