about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-15 22:08:21 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-15 22:08:21 -0700
commit2c3afb53dda7c83c70be4c12bd76930fe568b860 (patch)
tree4d326dae46e980614b29231c976aaf8099c565c6
parent38a8e1c9cf8a7a8b5f88c63e0a429c8dee2fe4e3 (diff)
downloadmu-2c3afb53dda7c83c70be4c12bd76930fe568b860.tar.gz
1793 - rudimentary sandboxing for scenarios in the environment
-rw-r--r--050scenario.cc2
-rw-r--r--081run_interactive.cc11
2 files changed, 11 insertions, 2 deletions
diff --git a/050scenario.cc b/050scenario.cc
index debace02..8f3ec77e 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -131,7 +131,7 @@ const scenario* Current_scenario = NULL;
 void run_mu_scenario(const scenario& s) {
   Current_scenario = &s;
   bool not_already_inside_test = !Trace_stream;
-//?   cerr << s.name << '\n'; //? 11
+//?   cerr << s.name << '\n'; //? 12
   if (not_already_inside_test) {
     Trace_file = s.name;
     Trace_stream = new trace_stream;
diff --git a/081run_interactive.cc b/081run_interactive.cc
index ab13291d..1d317d4b 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -43,11 +43,20 @@ bool Running_interactive = false;
 :(before "End Setup")
 Running_interactive = false;
 :(code)
-// reads a string, tries to call it as code, saving all warnings.
+// reads a string, tries to call it as code (treating it as a test), saving
+// all warnings.
 // returns true if successfully called (no errors found during load and transform)
 bool run_interactive(long long int address) {
   if (Recipe_ordinal.find("interactive") == Recipe_ordinal.end())
     Recipe_ordinal["interactive"] = Next_recipe_ordinal++;
+  // try to sandbox the run as best you can
+  // todo: test this
+  if (!Current_scenario) {
+    // not already sandboxed
+    for (long long int i = 1; i < Reserved_for_tests; ++i)
+      Memory.erase(i);
+    Name[Recipe_ordinal["interactive"]].clear();
+  }
   string command = trim(strip_comments(to_string(address)));
   if (command.empty()) return false;
   Recipe.erase(Recipe_ordinal["interactive"]);