summaryrefslogtreecommitdiffstats
path: root/generic/tclInterp.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-12-29 14:55:42 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-12-29 14:55:42 (GMT)
commitf529e237b5116ef60425a6cd231f88167ff6bf05 (patch)
tree3a75da09f1e7e848542384d80a279925e2ee7d74 /generic/tclInterp.c
parent59172cf14f46e7f765d6bcce585b735629d1873f (diff)
downloadtcl-f529e237b5116ef60425a6cd231f88167ff6bf05.zip
tcl-f529e237b5116ef60425a6cd231f88167ff6bf05.tar.gz
tcl-f529e237b5116ef60425a6cd231f88167ff6bf05.tar.bz2
[Bug 2895741]: Make min() and max() supported in safe interpreters.
Diffstat (limited to 'generic/tclInterp.c')
-rw-r--r--generic/tclInterp.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index b724abf..a9adec1 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInterp.c,v 1.109 2009/12/28 09:58:14 dkf Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.110 2009/12/29 14:55:42 dkf Exp $
*/
#include "tclInt.h"
@@ -2960,9 +2960,26 @@ Tcl_MakeSafe(
{
Tcl_Channel chan; /* Channel to remove from safe interpreter. */
Interp *iPtr = (Interp *) interp;
+ Tcl_Interp *master = ((InterpInfo*) iPtr->interpInfo)->slave.masterInterp;
TclHideUnsafeCommands(interp);
+ if (master != NULL) {
+ /*
+ * Alias these function implementations in the slave to those in the
+ * master; the overall implementations are safe, but they're normally
+ * defined by init.tcl which is not sourced by safe interpreters.
+ * Assume these functions all work. [Bug 2895741]
+ */
+
+ (void) Tcl_Eval(interp,
+ "namespace eval ::tcl {namespace eval mathfunc {}}");
+ (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::min", master,
+ "::tcl::mathfunc::min", 0, NULL);
+ (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::max", master,
+ "::tcl::mathfunc::max", 0, NULL);
+ }
+
iPtr->flags |= SAFE_INTERP;
/*