From f433d710d0ab3b367cc4a851cdfb81c5405bb7f8 Mon Sep 17 00:00:00 2001 From: shugo Date: Wed, 13 Aug 2008 07:25:05 +0000 Subject: * object.c (rb_obj_untrusted): new method Object#untrusted?. (rb_obj_untrust): new method Object#untrust. (rb_obj_trust): new method Object#trust. * array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c, string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c, ruby.c, marshal.c: fixes for Object#untrusted?. * test/ruby/test_module.rb, test/ruby/test_array.rb, test/ruby/test_object.rb, test/ruby/test_string.rb, test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for Object#untrusted?. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 59f5fe3f72..941f3ffac4 100644 --- a/array.c +++ b/array.c @@ -54,7 +54,7 @@ static inline void rb_ary_modify_check(VALUE ary) { if (OBJ_FROZEN(ary)) rb_error_frozen("array"); - if (!OBJ_TAINTED(ary) && rb_safe_level() >= 4) + if (!OBJ_UNTRUSTED(ary) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify array"); } @@ -1263,10 +1263,12 @@ rb_ary_join(VALUE ary, VALUE sep) { long len = 1, i; int taint = Qfalse; + int untrust = Qfalse; VALUE result, tmp; if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0); if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue; + if (OBJ_UNTRUSTED(ary) || OBJ_UNTRUSTED(sep)) untrust = Qtrue; for (i=0; i 0) rb_str_buf_cat2(str, ", "); rb_str_buf_append(str, s); } rb_str_buf_cat2(str, "]"); if (tainted) OBJ_TAINT(str); + if (untrust) OBJ_UNTRUST(str); return str; } @@ -2952,7 +2959,7 @@ rb_ary_flatten(int argc, VALUE *argv, VALUE ary) if (level == 0) return ary; result = flatten(ary, level, &mod); - if (OBJ_TAINTED(ary)) OBJ_TAINT(result); + OBJ_INFECT(result, ary); return result; } -- cgit v1.2.3