summaryrefslogtreecommitdiffstats
path: root/unix
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 /unix
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).
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c20
1 files changed, 9 insertions, 11 deletions
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: ",