summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-10-26 13:59:28 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-10-26 13:59:28 (GMT)
commit408495bbff42d176d340658977bf1942b11495cf (patch)
tree159042abe433413100aba85a667c90140def1d07
parent74c67fdfe6a0ffd668bac120a258b398bd2feb97 (diff)
downloadtcl-408495bbff42d176d340658977bf1942b11495cf.zip
tcl-408495bbff42d176d340658977bf1942b11495cf.tar.gz
tcl-408495bbff42d176d340658977bf1942b11495cf.tar.bz2
* unix/tclUnixSock.c (TcpGetOptionProc): Prevent crash if interp is
* win/tclWinSock.c (TcpGetOptionProc): NULL (a legal situation).
-rw-r--r--ChangeLog10
-rw-r--r--unix/tclUnixSock.c20
-rw-r--r--win/tclWinSock.c5
3 files changed, 19 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 39f8f9b..46f3e2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,18 @@
+2010-10-26 Donal K. Fellows <dkf@users.sf.net>
+
+ * unix/tclUnixSock.c (TcpGetOptionProc): Prevent crash if interp is
+ * win/tclWinSock.c (TcpGetOptionProc): NULL (a legal situation).
+
2010-10-26 Reinhard Max <max@suse.de>
* unix/tclUnixSock.c (TcpGetOptionProc): Added support for
- ::tcl::unsupported::noReverseDNS, which if set, prevents
+ ::tcl::unsupported::noReverseDNS, which if set to any value, prevents
[fconfigure -sockname] and [fconfigure -peername] from doing
reverse DNS queries.
2010-10-17 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
- * doc/info.n : [Patch 2995655] :
+ * doc/info.n: [Patch 2995655]:
* generic/tclBasic.c: Report inner contexts in [info errorstack]
* generic/tclCompCmds.c:
* generic/tclCompile.c:
@@ -18,7 +23,6 @@
* tests/error.test:
* tests/result.test:
-
2010-10-20 Donal K. Fellows <dkf@users.sf.net>
* generic/tclCompCmds.c (TclCompileDictForCmd): Update the compilation
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 7507356..3455e29 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixSock.c,v 1.29 2010/10/26 13:14:09 rmax Exp $
+ * RCS: @(#) $Id: tclUnixSock.c,v 1.30 2010/10/26 13:59:28 dkf Exp $
*/
#include "tclInt.h"
@@ -620,10 +620,10 @@ TcpGetOptionProc(
* initialized by caller. */
{
TcpState *statePtr = (TcpState *) instanceData;
-
char host[NI_MAXHOST], port[NI_MAXSERV];
size_t len = 0;
int reverseDNS = 0;
+#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
if (optionName != NULL) {
len = strlen(optionName);
@@ -645,7 +645,7 @@ TcpGetOptionProc(
return TCL_OK;
}
- if (Tcl_GetVar(interp, "::tcl::unsupported::noReverseDNS", 0) != NULL) {
+ if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) {
reverseDNS = NI_NUMERICHOST;
}
@@ -668,11 +668,10 @@ TcpGetOptionProc(
sizeof(port), reverseDNS | NI_NUMERICSERV);
Tcl_DStringAppendElement(dsPtr, host);
Tcl_DStringAppendElement(dsPtr, port);
- if (len == 0) {
- Tcl_DStringEndSublist(dsPtr);
- } else {
- return TCL_OK;
- }
+ if (len) {
+ return TCL_OK;
+ }
+ Tcl_DStringEndSublist(dsPtr);
} else {
/*
* getpeername failed - but if we were asked for all the options
@@ -743,11 +742,10 @@ TcpGetOptionProc(
}
}
if (found) {
- if (len == 0) {
- Tcl_DStringEndSublist(dsPtr);
- } else {
+ if (len) {
return TCL_OK;
}
+ Tcl_DStringEndSublist(dsPtr);
} else {
if (interp) {
Tcl_AppendResult(interp, "can't get sockname: ",
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 7f3dbac..347aa1c 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinSock.c,v 1.78 2010/10/26 13:14:09 rmax Exp $
+ * RCS: @(#) $Id: tclWinSock.c,v 1.79 2010/10/26 13:59:28 dkf Exp $
*
* -----------------------------------------------------------------------
*
@@ -2079,6 +2079,7 @@ TcpGetOptionProc(
SOCKET sock;
size_t len = 0;
int reverseDNS = 0;
+#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
/*
* Check that WinSock is initialized; do not call it if not, to prevent
@@ -2118,7 +2119,7 @@ TcpGetOptionProc(
return TCL_OK;
}
- if (Tcl_GetVar(interp, "::tcl::unsupported::noReverseDNS", 0) != NULL) {
+ if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) {
reverseDNS = NI_NUMERICHOST;
}