Fix clang warning, IPv6 address comment, buffer size typo

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.
This commit is contained in:
teor
2014-12-20 22:20:54 +11:00
parent f7e8bc2b4b
commit 6a9cae2e1d
4 changed files with 19 additions and 3 deletions
+6
View File
@@ -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.
+2 -1
View 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;
+1 -1
View 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;
+10 -1
View 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)