Changeset 151

Show
Ignore:
Timestamp:
10/10/2007 14:43:25 (12 months ago)
Author:
why
Message:

* ext/sand_table/sand_table.c: don't allow method_missing to be used directly to call any of Object's built-in instance methods. those should be handled by the proxy object.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ext/sand_table/sand_table.c

    r150 r151  
    2121 
    2222static VALUE Qimport, Qset, Qinit, Qload, Qenv, Qio, Qreal, Qref, Qall; 
    23 VALUE rb_cSandbox, rb_cSandboxFull, rb_cSandboxSafe, rb_eSandboxException, rb_cSandboxRef, rb_cSandboxWick, rb_cSandboxTransfer; 
     23VALUE rb_cSandbox, rb_cSandboxFull, rb_cSandboxSafe, rb_eSandboxException, rb_cSandboxRef,  
     24      rb_cSandboxWick, rb_cSandboxTransfer, rb_aUnsafeMethods; 
    2425static ID s_options, s_to_s, s_set_ivar, s_marshal_dump; 
    2526 
     
    10511052    /* FIXME: oh, wait, this shouldn't happen! */ 
    10521053    rb_raise(rb_eNoMethodError, "no link for %s", RSTRING(rb_inspect(self))->ptr); 
     1054  } else if (!SYMBOL_P(argv[0])) { 
     1055    rb_raise(rb_eArgError, "method_missing expects a symbolized method name"); 
     1056  } else if (rb_ary_includes(rb_aUnsafeMethods, argv[0])) { 
     1057    rb_raise(rb_eArgError, "method cannot be called"); 
    10531058  } else { 
    10541059    int i; 
     
    31723177void Init_sand_table() 
    31733178{ 
     3179  long i; 
     3180  VALUE obj_methods = rb_class_instance_methods(0, NULL, rb_cObject); 
     3181 
    31743182  ruby_sandbox_save = sandbox_save; 
    31753183  ruby_sandbox_restore = sandbox_restore; 
     
    31803188  Init_kit_env(&base, 0); 
    31813189  Init_kit_real(&base, 0); 
     3190 
     3191  rb_aUnsafeMethods = rb_ary_new(); 
     3192  for (i = 0; i < RARRAY_LEN(obj_methods); i++) 
     3193    rb_ary_push(rb_aUnsafeMethods, rb_str_intern(rb_ary_entry(obj_methods, i))); 
     3194  rb_global_variable(&rb_aUnsafeMethods); 
    31823195 
    31833196  rb_cSandbox = rb_define_module("Sandbox");