mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
nodelist: Clear buffers and detect more caller errors in describe.c
Part of 21003.
This commit is contained in:
parent
23844bc739
commit
e8ba094c3e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user