summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-06-16 16:27:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-06-16 16:27:01 (GMT)
commitb36880503c6464eb0404613b2e6f0ea9605d33ef (patch)
tree8e125264e32e68a389be074bfb8795cd212b9114 /unix/tclUnixFile.c
parent3c2b67a4d35a1953c3b0d4f3a541f1e792ae5495 (diff)
parent99d3f3c9f3dc5752e4887e6dec6661fabd80cd50 (diff)
downloadtcl-b36880503c6464eb0404613b2e6f0ea9605d33ef.zip
tcl-b36880503c6464eb0404613b2e6f0ea9605d33ef.tar.gz
tcl-b36880503c6464eb0404613b2e6f0ea9605d33ef.tar.bz2
Merge tip of core-8-6-branch
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);