diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2020-04-08 19:09:53 +0300 |
---|---|---|
committer | rl1987 <rl1987@users.noreply.github.com> | 2020-05-21 13:41:19 +0300 |
commit | 8ab7e30484c307ade39277488b954a5f21b5f6e5 (patch) | |
tree | 87b363fae8f9573f33a3800f06b11a3d93e06406 /src/feature/nodelist | |
parent | d8e24684b6607baa95dd4950a14ea671edcef1dc (diff) | |
download | tor-8ab7e30484c307ade39277488b954a5f21b5f6e5.tar.gz tor-8ab7e30484c307ade39277488b954a5f21b5f6e5.zip |
Check that fmt_addr32() returned non-empty string before putting it into documents
Diffstat (limited to 'src/feature/nodelist')
-rw-r--r-- | src/feature/nodelist/fmt_routerstatus.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/feature/nodelist/fmt_routerstatus.c b/src/feature/nodelist/fmt_routerstatus.c index 0cf4a6eeab..6cecbf4df8 100644 --- a/src/feature/nodelist/fmt_routerstatus.c +++ b/src/feature/nodelist/fmt_routerstatus.c @@ -53,20 +53,23 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version, char digest64[BASE64_DIGEST_LEN+1]; smartlist_t *chunks = smartlist_new(); + const char *ip_str = fmt_addr32(rs->addr); + format_iso_time(published, rs->published_on); digest_to_base64(identity64, rs->identity_digest); digest_to_base64(digest64, rs->descriptor_digest); - smartlist_add_asprintf(chunks, - "r %s %s %s%s%s %s %d %d\n", - rs->nickname, - identity64, - (format==NS_V3_CONSENSUS_MICRODESC)?"":digest64, - (format==NS_V3_CONSENSUS_MICRODESC)?"":" ", - published, - fmt_addr32(rs->addr), - (int)rs->or_port, - (int)rs->dir_port); + if (ip_str[0]) + smartlist_add_asprintf(chunks, + "r %s %s %s%s%s %s %d %d\n", + rs->nickname, + identity64, + (format==NS_V3_CONSENSUS_MICRODESC)?"":digest64, + (format==NS_V3_CONSENSUS_MICRODESC)?"":" ", + published, + ip_str, + (int)rs->or_port, + (int)rs->dir_port); /* TODO: Maybe we want to pass in what we need to build the rest of * this here, instead of in the caller. Then we could use the |