summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-09-24 14:14:11 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-09-24 14:14:11 (GMT)
commit7e7a246d3ed9305597efc22b09273a9faafc5c68 (patch)
tree38d8edad193bc5e672d0f3b7a509d0fa705818ea /unix/tclUnixFile.c
parent8e394f80fcf5eca711529b960b1366712ea147b8 (diff)
parent6f3388528ef453d29fbddba3f5a054d2f5268207 (diff)
downloadtcl-7e7a246d3ed9305597efc22b09273a9faafc5c68.zip
tcl-7e7a246d3ed9305597efc22b09273a9faafc5c68.tar.gz
tcl-7e7a246d3ed9305597efc22b09273a9faafc5c68.tar.bz2
Merge latest TIP #414 implementation (branch initsubsystems).
Diffstat (limited to 'unix/tclUnixFile.c')
-rw-r--r--unix/tclUnixFile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 5bfe5d9..7ffbf8d 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -155,6 +155,11 @@ TclpFindExecutable(
goto done;
}
+ if (TclpGetCwd(NULL, &cwd) == NULL) {
+ TclSetObjNameOfExecutable(Tcl_NewObj(), NULL);
+ goto done;
+ }
+
/*
* The name is relative to the current working directory. First strip off
* a leading "./", if any, then add the full path name of the current
@@ -168,8 +173,6 @@ TclpFindExecutable(
Tcl_DStringInit(&nameString);
Tcl_DStringAppend(&nameString, name, -1);
- TclpGetCwd(NULL, &cwd);
-
Tcl_DStringFree(&buffer);
Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&cwd),
Tcl_DStringLength(&cwd), &buffer);
@@ -1105,6 +1108,12 @@ TclNativeCreateNativeRep(
str = Tcl_GetStringFromObj(validPathPtr, &len);
Tcl_UtfToExternalDString(NULL, str, len, &ds);
len = Tcl_DStringLength(&ds) + sizeof(char);
+ if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
+ /* See bug [3118489]: NUL in filenames */
+ Tcl_DecrRefCount(validPathPtr);
+ Tcl_DStringFree(&ds);
+ return NULL;
+ }
Tcl_DecrRefCount(validPathPtr);
nativePathPtr = ckalloc(len);
memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len);