diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-27 15:13:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-27 15:13:36 (GMT) |
commit | 8225b1fd250bbd3d71a52ca514ae343a91dfcdc5 (patch) | |
tree | a91dde691bf66a3e79e57ac8058f0ab98348bc68 /unix/tclUnixPipe.c | |
parent | af64c95042a9706c6d45118c8f341aafa5c26686 (diff) | |
parent | 192dc7dffdb4bd9d434e1f54830711df4fed4672 (diff) | |
download | tcl-8225b1fd250bbd3d71a52ca514ae343a91dfcdc5.zip tcl-8225b1fd250bbd3d71a52ca514ae343a91dfcdc5.tar.gz tcl-8225b1fd250bbd3d71a52ca514ae343a91dfcdc5.tar.bz2 |
Rebase to 9.0. Add more filname encoding checks
Diffstat (limited to 'unix/tclUnixPipe.c')
-rw-r--r-- | unix/tclUnixPipe.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 4e8a758..8c0b378 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -152,7 +152,11 @@ TclpOpenFile( const char *native; Tcl_DString ds; - native = Tcl_UtfToExternalDString(NULL, fname, TCL_INDEX_NONE, &ds); + if (Tcl_UtfToExternalDStringEx(NULL, NULL, fname, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) { + Tcl_DStringFree(&ds); + return NULL; + } + native = Tcl_DStringValue(&ds); fd = TclOSopen(native, mode, 0666); /* INTL: Native. */ Tcl_DStringFree(&ds); if (fd != -1) { @@ -209,7 +213,12 @@ TclpCreateTempFile( Tcl_DString dstring; char *native; - native = Tcl_UtfToExternalDString(NULL, contents, TCL_INDEX_NONE, &dstring); + if (Tcl_UtfToExternalDStringEx(NULL, NULL, contents, TCL_INDEX_NONE, 0, &dstring, NULL) != TCL_OK) { + close(fd); + Tcl_DStringFree(&dstring); + return NULL; + } + native = Tcl_DStringValue(&dstring); if (write(fd, native, Tcl_DStringLength(&dstring)) == -1) { close(fd); Tcl_DStringFree(&dstring); @@ -452,7 +461,15 @@ TclpCreateProcess( newArgv = (char **)TclStackAlloc(interp, (argc+1) * sizeof(char *)); newArgv[argc] = NULL; for (i = 0; i < argc; i++) { - newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], TCL_INDEX_NONE, &dsArray[i]); + if (Tcl_UtfToExternalDStringEx(interp, NULL, argv[i], TCL_INDEX_NONE, 0, &dsArray[i], NULL) != TCL_OK) { + while (i-- > 0) { + Tcl_DStringFree(&dsArray[i]); + } + TclStackFree(interp, newArgv); + TclStackFree(interp, dsArray); + goto error; + } + newArgv[i] = Tcl_DStringValue(&dsArray[i]); } #if defined(HAVE_VFORK) || defined(HAVE_POSIX_SPAWNP) |