]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix some checks of tor_inet_ntoa() return value
authorrl1987 <rl1987@users.noreply.github.com>
Fri, 5 Jun 2020 08:49:24 +0000 (11:49 +0300)
committerrl1987 <rl1987@users.noreply.github.com>
Fri, 5 Jun 2020 08:49:24 +0000 (11:49 +0300)
Also, fix a format string.

src/feature/relay/dns.c
src/lib/net/address.c

index 26e9c6bf1303b7ae1c4c2d0f71f33f82d71a9a92..b83bd9b7583517e1aa07e003d73e99bae3e435e1 100644 (file)
@@ -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);
       }
index d99a1795f2cda79c5c653bb90eb97fa8c11b8ae3..567048b5a60f7e1c0b4bb830cdf10a7c90566006 100644 (file)
@@ -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);
   }