1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* struct.c (rb_struct_modify): should check frozen and taint

status.

* eval.c (rb_undefined): do not recurse if method_missing is
  undefined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-08-06 03:10:24 +00:00
parent 42d1f98904
commit 3955aef501
5 changed files with 34 additions and 7 deletions

View file

@ -1,3 +1,13 @@
Mon Aug 6 00:35:03 2001 Guy Decoux <decoux@moulon.inra.fr>
* struct.c (rb_struct_modify): should check frozen and taint
status.
Sun Aug 5 07:46:18 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* eval.c (rb_undefined): do not recurse if method_missing is
undefined.
Wed Aug 1 20:45:14 2001 Usaku Nakamura <usa@ruby-lang.org>
* win32/Makefile.sub: changed path separator of $LIB to '\'.

10
eval.c
View file

@ -4135,12 +4135,18 @@ rb_undefined(obj, id, argc, argv, call_status)
{
VALUE *nargv;
last_call_status = call_status;
if (id == missing) {
PUSH_FRAME();
rb_f_missing(argc, argv, obj);
POP_FRAME();
}
nargv = ALLOCA_N(VALUE, argc+1);
nargv[0] = ID2SYM(id);
MEMCPY(nargv+1, argv, VALUE, argc);
last_call_status = call_status;
return rb_funcall2(obj, missing, argc+1, nargv);
}

2
gc.c
View file

@ -963,7 +963,7 @@ rb_gc()
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__) && (defined(__i386__) || defined(__m68k__))
# if defined(__GNUC__) && (defined(__i386__) || defined(__mc68000__))
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);

View file

@ -124,6 +124,15 @@ static VALUE (*ref_func[10])() = {
rb_struct_ref9,
};
static void
rb_struct_modify(s)
VALUE s;
{
if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
if (!OBJ_TAINTED(s) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify Struct");
}
static VALUE
rb_struct_set(obj, val)
VALUE obj, val;
@ -135,6 +144,7 @@ rb_struct_set(obj, val)
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
rb_struct_modify(obj);
for (i=0; i<RARRAY(member)->len; i++) {
slot = RARRAY(member)->ptr[i];
if (rb_id_attrset(SYM2ID(slot)) == rb_frame_last_func()) {
@ -253,6 +263,7 @@ rb_struct_initialize(self, values)
VALUE size;
long n;
rb_struct_modify(self);
size = iv_get(klass, "__size__");
n = FIX2LONG(size);
if (n < RARRAY(values)->len) {
@ -473,7 +484,7 @@ rb_struct_aset_id(s, id, val)
rb_bug("non-initialized struct");
}
if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
rb_struct_modify(s);
len = RARRAY(member)->len;
for (i=0; i<len; i++) {
if (SYM2ID(RARRAY(member)->ptr[i]) == id) {
@ -504,7 +515,7 @@ rb_struct_aset(s, idx, val)
rb_raise(rb_eIndexError, "offset %d too large for struct(size:%d)",
i, RSTRUCT(s)->len);
}
if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
rb_struct_modify(s);
return RSTRUCT(s)->ptr[i] = val;
}

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.4"
#define RUBY_RELEASE_DATE "2001-07-31"
#define RUBY_RELEASE_DATE "2001-08-06"
#define RUBY_VERSION_CODE 164
#define RUBY_RELEASE_CODE 20010731
#define RUBY_RELEASE_CODE 20010806