Merge branch 'tor-github/pr/1323'

This commit is contained in:
George Kadianakis 2019-09-17 14:51:43 +03:00
commit 585eaa123f
4 changed files with 22 additions and 11 deletions

4
changes/ticket31687_1 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (compilation):
- Suppress spurious float-conversion warnings from GCC when calling
floating-point classifier functions on FreeBSD. Fixes part of bug
31687; bugfix on 0.3.1.5-alpha.

5
changes/ticket31687_2 Normal file
View File

@ -0,0 +1,5 @@
o Minor bugfixes (FreeBSD, PF-based proxy, IPv6):
- When extracting an IPv6 address from a PF-based proxy, verify
that we are actually configured to receive an IPv6 address,
and log an internal error if not. Fixes part of bug 31687;
bugfix on 0.2.3.4-alpha.

View File

@ -2560,8 +2560,11 @@ destination_from_pf(entry_connection_t *conn, socks_request_t *req)
} else if (proxy_sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)proxy_sa;
pnl.af = AF_INET6;
memcpy(&pnl.saddr.v6, tor_addr_to_in6(&ENTRY_TO_CONN(conn)->addr),
sizeof(struct in6_addr));
const struct in6_addr *dest_in6 =
tor_addr_to_in6(&ENTRY_TO_CONN(conn)->addr);
if (BUG(!dest_in6))
return -1;
memcpy(&pnl.saddr.v6, dest_in6, sizeof(struct in6_addr));
pnl.sport = htons(ENTRY_TO_CONN(conn)->port);
memcpy(&pnl.daddr.v6, &sin6->sin6_addr, sizeof(struct in6_addr));
pnl.dport = sin6->sin6_port;

View File

@ -62,12 +62,16 @@ clamp_double_to_int64(double number)
{
int exponent;
#if defined(MINGW_ANY) && GCC_VERSION >= 409
#if (defined(MINGW_ANY)||defined(__FreeBSD__)) && GCC_VERSION >= 409
/*
Mingw's math.h uses gcc's __builtin_choose_expr() facility to declare
isnan, isfinite, and signbit. But as implemented in at least some
versions of gcc, __builtin_choose_expr() can generate type warnings
even from branches that are not taken. So, suppress those warnings.
FreeBSD's math.h uses an __fp_type_select() macro, which dispatches
based on sizeof -- again, this can generate type warnings from
branches that are not taken.
*/
#define PROBLEMATIC_FLOAT_CONVERSION_WARNING
DISABLE_GCC_WARNING(float-conversion)
@ -123,16 +127,12 @@ int
tor_isinf(double x)
{
/* Same as above, work around the "double promotion" warnings */
#if defined(MINGW_ANY) && GCC_VERSION >= 409
#define PROBLEMATIC_FLOAT_CONVERSION_WARNING
#ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
DISABLE_GCC_WARNING(float-conversion)
#endif /* defined(MINGW_ANY) && GCC_VERSION >= 409 */
#if defined(__clang__)
#if __has_warning("-Wdouble-promotion")
#define PROBLEMATIC_DOUBLE_PROMOTION_WARNING
#endif
#ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
DISABLE_GCC_WARNING(double-promotion)
#endif
#endif /* defined(__clang__) */
return isinf(x);
#ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
ENABLE_GCC_WARNING(double-promotion)
@ -141,4 +141,3 @@ ENABLE_GCC_WARNING(double-promotion)
ENABLE_GCC_WARNING(float-conversion)
#endif
}