summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2017-04-27 10:51:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2017-04-27 10:51:50 (GMT)
commit08266ba63bcae218ba1c574d6128462468670b80 (patch)
treec79464525a30e9ec7b22e50b073abb23b716c405 /unix
parent90fde58143eea5e3f626221a006cf6ac3e398ebe (diff)
parentada887f2ef7727135a81639bc1fd6513ef6c8f43 (diff)
downloadtcl-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')
-rw-r--r--unix/tclUnixChan.c17
-rw-r--r--unix/tclUnixInit.c58
-rw-r--r--unix/tclUnixSock.c34
3 files changed, 75 insertions, 34 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 6418f48..3bf64d6 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -605,7 +605,6 @@ TtySetOptionProc(
return TCL_OK;
}
-
/*
* Option -handshake none|xonxoff|rtscts|dtrdsr
*/
@@ -706,6 +705,7 @@ TtySetOptionProc(
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
+
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
#if defined(TIOCMGET) && defined(TIOCMSET)
int i, control, flag;
@@ -882,6 +882,7 @@ TtyGetOptionProc(
* Option is readonly and returned by [fconfigure chan -ttystatus] but not
* returned by unnamed [fconfigure chan].
*/
+
if ((len > 4) && (strncmp(optionName, "-ttystatus", len) == 0)) {
int status;
@@ -894,12 +895,10 @@ TtyGetOptionProc(
if (valid) {
return TCL_OK;
}
- return Tcl_BadChannelOption(interp, optionName, "mode"
- " queue ttystatus xchar"
- );
+ return Tcl_BadChannelOption(interp, optionName,
+ "mode queue ttystatus xchar");
}
-
static const struct {int baud; speed_t speed;} speeds[] = {
#ifdef B0
{0, B0},
@@ -1023,7 +1022,7 @@ static const struct {int baud; speed_t speed;} speeds[] = {
#endif
{-1, 0}
};
-
+
/*
*---------------------------------------------------------------------------
*
@@ -1315,7 +1314,8 @@ TtyParseMode(
static void
TtyInit(
- int fd) /* Open file descriptor for serial port to be initialized. */
+ int fd) /* Open file descriptor for serial port to be
+ * initialized. */
{
struct termios iostate;
tcgetattr(fd, &iostate);
@@ -1325,8 +1325,7 @@ TtyInit(
|| iostate.c_lflag != 0
|| iostate.c_cflag & CREAD
|| iostate.c_cc[VMIN] != 1
- || iostate.c_cc[VTIME] != 0)
- {
+ || iostate.c_cc[VTIME] != 0) {
iostate.c_iflag = IGNBRK;
iostate.c_oflag = 0;
iostate.c_lflag = 0;
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 1e35b92..80d315e 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -737,6 +737,43 @@ Tcl_GetEncodingNameFromEnvironment(
*----------------------------------------------------------------------
*/
+#if defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020
+/*
+ * Helper because whether CFLocaleCopyCurrent and CFLocaleGetIdentifier are
+ * strongly or weakly bound varies by version of OSX, triggering warnings.
+ */
+
+static inline void
+InitMacLocaleInfoVar(
+ CFLocaleRef (*localeCopyCurrent)(void),
+ CFStringRef (*localeGetIdentifier)(CFLocaleRef),
+ Tcl_Interp *interp)
+{
+ CFLocaleRef localeRef;
+ CFStringRef locale;
+ char loc[256];
+
+ if (localeCopyCurrent == NULL || localeGetIdentifier == NULL) {
+ return;
+ }
+
+ localeRef = localeCopyCurrent();
+ if (!localeRef) {
+ return;
+ }
+
+ locale = localeGetIdentifier(localeRef);
+ if (locale && CFStringGetCString(locale, loc, 256,
+ kCFStringEncodingUTF8)) {
+ if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
+ Tcl_ResetResult(interp);
+ }
+ Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
+ }
+ CFRelease(localeRef);
+}
+#endif /*defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020*/
+
void
TclpSetVariables(
Tcl_Interp *interp)
@@ -755,29 +792,12 @@ TclpSetVariables(
#ifdef HAVE_COREFOUNDATION
char tclLibPath[MAXPATHLEN + 1];
-#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
/*
* Set msgcat fallback locale to current CFLocale identifier.
*/
- CFLocaleRef localeRef;
-
- if (&CFLocaleCopyCurrent != NULL && &CFLocaleGetIdentifier != NULL &&
- (localeRef = CFLocaleCopyCurrent())) {
- CFStringRef locale = CFLocaleGetIdentifier(localeRef);
-
- if (locale) {
- char loc[256];
-
- if (CFStringGetCString(locale, loc, 256, kCFStringEncodingUTF8)) {
- if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
- Tcl_ResetResult(interp);
- }
- Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
- }
- }
- CFRelease(localeRef);
- }
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
+ InitMacLocaleInfoVar(CFLocaleCopyCurrent, CFLocaleGetIdentifier, interp);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED > 1020 */
if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) {
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 */