]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix clang warning, IPv6 address comment, buffer size typo
authorteor <teor2345@gmail.com>
Sat, 20 Dec 2014 11:20:54 +0000 (22:20 +1100)
committerteor <teor2345@gmail.com>
Sat, 20 Dec 2014 11:20:54 +0000 (22:20 +1100)
The address of an array in the middle of a structure will
always be non-NULL. clang recognises this and complains.
Disable the tautologous and redundant check to silence
this warning.

A comment about an IPv6 address string incorrectly refers
to an IPv4 address format.

A log buffer is sized 10024 rather than 10240.

Fixes bug 14001.

changes/bug14001-clang-warning [new file with mode: 0644]
src/common/address.c
src/common/log.c
src/or/connection_edge.c

diff --git a/changes/bug14001-clang-warning b/changes/bug14001-clang-warning
new file mode 100644 (file)
index 0000000..b932af6
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - The address of an array in the middle of a structure will
+      always be non-NULL. clang recognises this and complains.
+      Disable the tautologous and redundant check to silence
+      this warning.
+      Fixes bug 14001.
index a3b5df66bce467008296ebcfb2fc357bdc9223fc..0b475fc9fda4488c2f33717c99d0074247fd4043 100644 (file)
@@ -1119,7 +1119,8 @@ fmt_addr32(uint32_t addr)
 int
 tor_addr_parse(tor_addr_t *addr, const char *src)
 {
-  char *tmp = NULL; /* Holds substring if we got a dotted quad. */
+  /* Holds substring of IPv6 address after removing square brackets */
+  char *tmp = NULL;
   int result;
   struct in_addr in_tmp;
   struct in6_addr in6_tmp;
index ad0da7da6babc726eb442c1282e26eedb19e8655..0a21ffbd44149e94063db563615625e764846863 100644 (file)
@@ -451,7 +451,7 @@ MOCK_IMPL(STATIC void,
 logv,(int severity, log_domain_mask_t domain, const char *funcname,
      const char *suffix, const char *format, va_list ap))
 {
-  char buf[10024];
+  char buf[10240];
   size_t msg_len = 0;
   int formatted = 0;
   logfile_t *lf;
index 9ace375d74cbdab857ac92fa7da715cdd174a3c0..9859cc26ea81c87e58050f4784c520ca17f36405 100644 (file)
@@ -744,8 +744,17 @@ connection_ap_fail_onehop(const char *failed_digest,
       /* we don't know the digest; have to compare addr:port */
       tor_addr_t addr;
       if (!build_state || !build_state->chosen_exit ||
-          !entry_conn->socks_request || !entry_conn->socks_request->address)
+          !entry_conn->socks_request) {
+        /* clang thinks that an array midway through a structure
+         * will never have a NULL address, under either:
+         * -Wpointer-bool-conversion if using !, or
+         * -Wtautological-pointer-compare if using == or !=
+         * It's probably right (unless pointers overflow and wrap),
+         * so we just skip this check
+         || !entry_conn->socks_request->address
+         */
         continue;
+      }
       if (tor_addr_parse(&addr, entry_conn->socks_request->address)<0 ||
           !tor_addr_eq(&build_state->chosen_exit->addr, &addr) ||
           build_state->chosen_exit->port != entry_conn->socks_request->port)