aboutsummaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-20 13:17:08 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-29 07:16:05 +1100
commit4db5a35e669a03db33d04632349ec95022de53cf (patch)
tree1ba01c524e2f34b74b8d57695729ea455987ea45 /src/or/nodelist.c
parent772577b547aa5e6b13b89f465acf656cd08f2917 (diff)
downloadtor-4db5a35e669a03db33d04632349ec95022de53cf.tar.gz
tor-4db5a35e669a03db33d04632349ec95022de53cf.zip
Consistently format addresses in node_get_address_string
Also, don't write to a buffer with length zero.
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index c8f93bf30c..28d874133c 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -863,13 +863,13 @@ node_get_prim_addr_ipv4h(const node_t *node)
void
node_get_address_string(const node_t *node, char *buf, size_t len)
{
- if (node->ri) {
- strlcpy(buf, fmt_addr32(node->ri->addr), len);
- } else if (node->rs) {
+ uint32_t ipv4_addr = node_get_prim_addr_ipv4h(node);
+
+ if (tor_addr_is_valid_ipv4h(ipv4_addr, 0)) {
tor_addr_t addr;
- tor_addr_from_ipv4h(&addr, node->rs->addr);
+ tor_addr_from_ipv4h(&addr, ipv4_addr);
tor_addr_to_str(buf, &addr, len, 0);
- } else {
+ } else if (len > 0) {
buf[0] = '\0';
}
}