diff options
Diffstat (limited to 'unix/tclUnixFile.c')
| -rw-r--r-- | unix/tclUnixFile.c | 59 | 
1 files changed, 38 insertions, 21 deletions
| diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 01fc6fe..2cb0027 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -470,7 +470,7 @@ NativeMatchType(  #ifndef MAC_OSX_TCL  	    || ((types->perm & TCL_GLOB_PERM_HIDDEN) &&  		(*nativeName != '.')) -#endif +#endif /* MAC_OSX_TCL */  		) {  	    return 0;  	} @@ -488,12 +488,10 @@ NativeMatchType(  		 * check that here:  		 */ -		if (types->type & TCL_GLOB_TYPE_LINK) { -		    if (TclOSlstat(nativeEntry, &buf) == 0) { -			if (S_ISLNK(buf.st_mode)) { -			    return 1; -			} -		    } +		if ((types->type & TCL_GLOB_TYPE_LINK) +			&& (TclOSlstat(nativeEntry, &buf) == 0) +			&& S_ISLNK(buf.st_mode)) { +		    return 1;  		}  		return 0;  	    } @@ -516,12 +514,10 @@ NativeMatchType(  	     */  	} else {  #ifdef S_ISLNK -	    if (types->type & TCL_GLOB_TYPE_LINK) { -		if (TclOSlstat(nativeEntry, &buf) == 0) { -		    if (S_ISLNK(buf.st_mode)) { -			goto filetypeOK; -		    } -		} +	    if ((types->type & TCL_GLOB_TYPE_LINK) +		    && (TclOSlstat(nativeEntry, &buf) == 0) +		    && S_ISLNK(buf.st_mode)) { +		goto filetypeOK;  	    }  #endif /* S_ISLNK */  	    return 0; @@ -717,9 +713,9 @@ TclpGetNativeCwd(      if (getcwd(buffer, MAXPATHLEN+1) == NULL) {		/* INTL: Native. */  	return NULL;      } -#endif +#endif /* USEGETWD */ -    if ((clientData == NULL) || strcmp(buffer, (const char*)clientData)) { +    if ((clientData == NULL) || strcmp(buffer, (const char *) clientData)) {  	char *newCd = ckalloc(strlen(buffer) + 1);  	strcpy(newCd, buffer); @@ -767,7 +763,7 @@ TclpGetCwd(      if (getwd(buffer) == NULL)				/* INTL: Native. */  #else      if (getcwd(buffer, MAXPATHLEN+1) == NULL)		/* INTL: Native. */ -#endif +#endif /* USEGETWD */      {  	if (interp != NULL) {  	    Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -823,7 +819,7 @@ TclpReadlink(      return Tcl_DStringValue(linkPtr);  #else      return NULL; -#endif +#endif /* !DJGPP */  }  /* @@ -857,7 +853,7 @@ TclpObjStat(  #ifdef S_IFLNK -Tcl_Obj* +Tcl_Obj *  TclpObjLink(      Tcl_Obj *pathPtr,      Tcl_Obj *toPtr, @@ -1109,6 +1105,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); @@ -1179,10 +1181,18 @@ TclpUtime(  {      return utime(Tcl_FSGetNativePath(pathPtr), tval);  } +  #ifdef __CYGWIN__ -int TclOSstat(const char *name, Tcl_StatBuf *statBuf) { + +int +TclOSstat( +    const char *name, +    void *cygstat) +{      struct stat buf; +    Tcl_StatBuf *statBuf = cygstat;      int result = stat(name, &buf); +      statBuf->st_mode = buf.st_mode;      statBuf->st_ino = buf.st_ino;      statBuf->st_dev = buf.st_dev; @@ -1196,9 +1206,16 @@ int TclOSstat(const char *name, Tcl_StatBuf *statBuf) {      statBuf->st_ctime = buf.st_ctime;      return result;  } -int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) { + +int +TclOSlstat( +    const char *name, +    void *cygstat) +{      struct stat buf; +    Tcl_StatBuf *statBuf = cygstat;      int result = lstat(name, &buf); +      statBuf->st_mode = buf.st_mode;      statBuf->st_ino = buf.st_ino;      statBuf->st_dev = buf.st_dev; @@ -1212,7 +1229,7 @@ int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) {      statBuf->st_ctime = buf.st_ctime;      return result;  } -#endif +#endif /* CYGWIN */  /*   * Local Variables: | 
