diff options
author | teor <teor@torproject.org> | 2019-08-19 16:36:20 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-08-22 23:51:32 +1000 |
commit | e8ba094c3e23f332dba5f2d9794c5e4c100ba568 (patch) | |
tree | 06f7d34c1c3992e06c02f1052dcaabd3aba54228 /src | |
parent | 23844bc7399a3517af23fe7f6429333b9f66df9e (diff) | |
download | tor-e8ba094c3e23f332dba5f2d9794c5e4c100ba568.tar.gz tor-e8ba094c3e23f332dba5f2d9794c5e4c100ba568.zip |
nodelist: Clear buffers and detect more caller errors in describe.c
Part of 21003.
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/nodelist/describe.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/feature/nodelist/describe.c b/src/feature/nodelist/describe.c index b64d4335a6..7ec18438c1 100644 --- a/src/feature/nodelist/describe.c +++ b/src/feature/nodelist/describe.c @@ -44,6 +44,13 @@ format_node_description(char *buf, if (!buf) return "<NULL BUFFER>"; + memset(buf, 0, NODE_DESC_BUF_LEN); + + if (!id_digest) { + memcpy(buf, "<NULL ID DIGEST>", 17); + return buf; + } + buf[0] = '$'; base16_encode(buf+1, HEX_DIGEST_LEN+1, id_digest, DIGEST_LEN); cp = buf+1+HEX_DIGEST_LEN; @@ -122,6 +129,8 @@ node_describe(const node_t *node) nickname = node->ri->nickname; addr32h = node->ri->addr; ipv6_addr = &node->ri->ipv6_addr; + } else { + return "<null rs and ri>"; } return format_node_description(buf, @@ -179,6 +188,16 @@ extend_info_describe(const extend_info_t *ei) void router_get_verbose_nickname(char *buf, const routerinfo_t *router) { + if (!buf) + return; + + memset(buf, 0, MAX_VERBOSE_NICKNAME_LEN+1); + + if (!router) { + memcpy(buf, "<null>", 7); + return; + } + buf[0] = '$'; base16_encode(buf+1, HEX_DIGEST_LEN+1, router->cache_info.identity_digest, DIGEST_LEN); |