From 82a85e5b1eb378f5a45526e1b098459f6b848f42 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 5 Apr 2022 07:18:37 +0000 Subject: RFE [655300]: Deprecate Tcl_MakeSafe() --- doc/CrtAlias.3 | 1 + generic/tcl.decls | 2 +- generic/tclDecls.h | 5 +++-- generic/tclInt.h | 2 ++ generic/tclInterp.c | 6 +++--- generic/tclStubInit.c | 2 ++ 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/CrtAlias.3 b/doc/CrtAlias.3 index 2623dcd..77a3bc2 100644 --- a/doc/CrtAlias.3 +++ b/doc/CrtAlias.3 @@ -160,6 +160,7 @@ parts, so safety is not guaranteed after calling \fBTcl_MakeSafe\fR. Callers will want to take care with their use of \fBTcl_MakeSafe\fR to avoid false claims of safety. For many situations, \fBTcl_CreateChild\fR may be a better choice, since it creates interpreters in a known-safe state. +\fBTcl_MakeSafe\fR is deprecated and will be removed in Tcl 9.0. .PP \fBTcl_GetChild\fR returns a pointer to a child interpreter of \fIinterp\fR. The child interpreter is identified by \fIname\fR. diff --git a/generic/tcl.decls b/generic/tcl.decls index 3cf794e..95b66f9 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -678,7 +678,7 @@ declare 187 { declare 189 { Tcl_Channel Tcl_MakeFileChannel(ClientData handle, int mode) } -declare 190 { +declare 190 {deprecated {}} { int Tcl_MakeSafe(Tcl_Interp *interp) } declare 191 { diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 790cddb..9a9be7a 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -602,7 +602,8 @@ EXTERN int Tcl_LinkVar(Tcl_Interp *interp, const char *varName, /* 189 */ EXTERN Tcl_Channel Tcl_MakeFileChannel(ClientData handle, int mode); /* 190 */ -EXTERN int Tcl_MakeSafe(Tcl_Interp *interp); +TCL_DEPRECATED("") +int Tcl_MakeSafe(Tcl_Interp *interp); /* 191 */ EXTERN Tcl_Channel Tcl_MakeTcpClientChannel(ClientData tcpSocket); /* 192 */ @@ -2188,7 +2189,7 @@ typedef struct TclStubs { int (*tcl_LinkVar) (Tcl_Interp *interp, const char *varName, void *addr, int type); /* 187 */ void (*reserved188)(void); Tcl_Channel (*tcl_MakeFileChannel) (ClientData handle, int mode); /* 189 */ - int (*tcl_MakeSafe) (Tcl_Interp *interp); /* 190 */ + TCL_DEPRECATED_API("") int (*tcl_MakeSafe) (Tcl_Interp *interp); /* 190 */ Tcl_Channel (*tcl_MakeTcpClientChannel) (ClientData tcpSocket); /* 191 */ char * (*tcl_Merge) (int argc, const char *const *argv); /* 192 */ Tcl_HashEntry * (*tcl_NextHashEntry) (Tcl_HashSearch *searchPtr); /* 193 */ diff --git a/generic/tclInt.h b/generic/tclInt.h index af839fc..2546e17 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3112,6 +3112,8 @@ MODULE_SCOPE Tcl_Obj * TclLsetFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Obj *valuePtr); MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name, const EnsembleImplMap map[]); +MODULE_SCOPE int TclMakeSafe(Tcl_Interp *interp); + MODULE_SCOPE int TclMaxListLength(const char *bytes, int numBytes, const char **endPtr); MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc, diff --git a/generic/tclInterp.c b/generic/tclInterp.c index e590775..115882b 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -2468,7 +2468,7 @@ ChildCreate( ((Interp *) parentInterp)->maxNestingDepth; if (safe) { - if (Tcl_MakeSafe(childInterp) == TCL_ERROR) { + if (TclMakeSafe(childInterp) == TCL_ERROR) { goto error; } } else { @@ -3253,7 +3253,7 @@ Tcl_IsSafe( /* *---------------------------------------------------------------------- * - * Tcl_MakeSafe -- + * TclMakeSafe -- * * Makes its argument interpreter contain only functionality that is * defined to be part of Safe Tcl. Unsafe commands are hidden, the env @@ -3270,7 +3270,7 @@ Tcl_IsSafe( */ int -Tcl_MakeSafe( +TclMakeSafe( Tcl_Interp *interp) /* Interpreter to be made safe. */ { Tcl_Channel chan; /* Channel to remove from safe interpreter. */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 257c3ce..7b682d2 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -713,6 +713,7 @@ static int utfNcasecmp(const char *s1, const char *s2, unsigned int n){ # define TclBN_s_mp_sqr 0 # undef TclBN_s_mp_sub # define TclBN_s_mp_sub 0 +# define Tcl_MakeSafe 0 #else /* TCL_NO_DEPRECATED */ # define Tcl_SeekOld seekOld # define Tcl_TellOld tellOld @@ -734,6 +735,7 @@ static int utfNcasecmp(const char *s1, const char *s2, unsigned int n){ # define TclGetCommandFullName Tcl_GetCommandFullName # define TclpLocaltime_unix TclpLocaltime # define TclpGmtime_unix TclpGmtime +# define Tcl_MakeSafe TclMakeSafe static int seekOld( -- cgit v0.12