diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2017-04-27 10:51:50 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2017-04-27 10:51:50 (GMT) |
commit | 08266ba63bcae218ba1c574d6128462468670b80 (patch) | |
tree | c79464525a30e9ec7b22e50b073abb23b716c405 /unix/tclUnixSock.c | |
parent | 90fde58143eea5e3f626221a006cf6ac3e398ebe (diff) | |
parent | ada887f2ef7727135a81639bc1fd6513ef6c8f43 (diff) | |
download | tcl-08266ba63bcae218ba1c574d6128462468670b80.zip tcl-08266ba63bcae218ba1c574d6128462468670b80.tar.gz tcl-08266ba63bcae218ba1c574d6128462468670b80.tar.bz2 |
[50750c735a] Fix broken test and stop reading uninit-but-allocated memory in zlib channel transform.
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r-- | unix/tclUnixSock.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index b404080..7a5497d 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -728,6 +728,33 @@ TcpClose2Proc( * *---------------------------------------------------------------------- */ + +#ifndef NEED_FAKE_RFC2553 +static inline int +IPv6AddressNeedsNumericRendering( + struct in6_addr addr) +{ + if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) { + return 1; + } + + /* + * The IN6_IS_ADDR_V4MAPPED macro has a problem with aliasing warnings on + * at least some versions of OSX. + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" + if (!IN6_IS_ADDR_V4MAPPED(&addr)) { +#pragma GCC diagnostic pop + return 0; + } + + return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0 + && addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0); +} +#endif /* NEED_FAKE_RFC2553 */ + static void TcpHostPortList( Tcl_Interp *interp, @@ -754,12 +781,7 @@ TcpHostPortList( } #ifndef NEED_FAKE_RFC2553 } else if (addr.sa.sa_family == AF_INET6) { - if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr, &in6addr_any)) - || (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) && - addr.sa6.sin6_addr.s6_addr[12] == 0 && - addr.sa6.sin6_addr.s6_addr[13] == 0 && - addr.sa6.sin6_addr.s6_addr[14] == 0 && - addr.sa6.sin6_addr.s6_addr[15] == 0)) { + if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) { flags |= NI_NUMERICHOST; } #endif /* NEED_FAKE_RFC2553 */ |