commit 3e4814edeb563535b0f3bf658c01d7c10d6b4aa2 Author: rl1987 rl1987@users.noreply.github.com Date: Fri Jun 5 11:49:24 2020 +0300
Fix some checks of tor_inet_ntoa() return value
Also, fix a format string. --- src/feature/relay/dns.c | 2 +- src/lib/net/address.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c index 26e9c6bf1..b83bd9b75 100644 --- a/src/feature/relay/dns.c +++ b/src/feature/relay/dns.c @@ -1881,7 +1881,7 @@ evdns_wildcard_check_callback(int result, char type, int count, int ttl, int ntoa_res; in.s_addr = addrs[i]; ntoa_res = tor_inet_ntoa(&in, answer_buf, sizeof(answer_buf)); - tor_assert_nonfatal(ntoa_res > 0); + tor_assert_nonfatal(ntoa_res >= 0); if (ntoa_res > 0) wildcard_increment_answer(answer_buf); } diff --git a/src/lib/net/address.c b/src/lib/net/address.c index d99a1795f..567048b5a 100644 --- a/src/lib/net/address.c +++ b/src/lib/net/address.c @@ -1207,10 +1207,10 @@ fmt_addr32(uint32_t addr) in.s_addr = htonl(addr);
success = tor_inet_ntoa(&in, buf, sizeof(buf)); - tor_assertf_nonfatal(success > 0, - "Failed to convert IP %04X to string", addr); + tor_assertf_nonfatal(success >= 0, + "Failed to convert IP 0x%08X (HBO) to string", addr);
- if (success <= 0) { + IF_BUG_ONCE(success < 0) { memset(buf, 0, INET_NTOA_BUF_LEN); }
tor-commits@lists.torproject.org