ruby-changes:11580
From: yugui <ko1@a...>
Date: Sun, 19 Apr 2009 22:34:04 +0900 (JST)
Subject: [ruby-changes:11580] Ruby:r23216 (ruby_1_9_1): merges r22954,r22955,r22956 and r22958 from trunk into ruby_1_9_1.
yugui 2009-04-19 22:33:09 +0900 (Sun, 19 Apr 2009) New Revision: 23216 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23216 Log: merges r22954,r22955,r22956 and r22958 from trunk into ruby_1_9_1. -- * proc.c (rb_proc_call): checks overflow. -- * proc.c (rb_proc_call, rb_node_arity, bmcall, curry): checks overflow. -- * proc.c (rb_proc_call, bmcall): commit miss. -- * proc.c (bmcall): should not uninitialized variable. a patch from pegacorn at [ruby-dev:38169]. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/proc.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 23215) +++ ruby_1_9_1/ChangeLog (revision 23216) @@ -1,3 +1,16 @@ +Sun Mar 15 02:09:31 2009 Nobuyoshi Nakada <nobu@r...> + + * proc.c (bmcall): should not uninitialized variable. a patch from + pegacorn at [ruby-dev:38169]. + +Sat Mar 14 18:18:08 2009 Nobuyoshi Nakada <nobu@r...> + + * proc.c (rb_proc_call, rb_node_arity, bmcall, curry): checks + overflow. + + * proc.c (rb_proc_parameters): unnamed_parameters() expects in + not VALUE. + Fri Mar 13 09:17:12 2009 Yukihiro Matsumoto <matz@r...> * lib/fileutils.rb (FileUtils#fu_get_gid): stringify group Index: ruby_1_9_1/proc.c =================================================================== --- ruby_1_9_1/proc.c (revision 23215) +++ ruby_1_9_1/proc.c (revision 23216) @@ -523,13 +523,27 @@ argc, argv, blockptr); } +#if SIZEOF_LONG > SIZEOF_INT +static inline int +check_argc(long argc) +{ + if (argc > INT_MAX || argc < 0) { + rb_raise(rb_eArgError, "too many arguments (%lu)", + (unsigned long)argc); + } + return (int)argc; +} +#else +#define check_argc(argc) (argc) +#endif + VALUE rb_proc_call(VALUE self, VALUE args) { rb_proc_t *proc; GetProcPtr(self, proc); return rb_vm_invoke_proc(GET_THREAD(), proc, proc->block.self, - RARRAY_LEN(args), RARRAY_PTR(args), 0); + check_argc(RARRAY_LEN(args)), RARRAY_PTR(args), 0); } VALUE @@ -794,7 +808,7 @@ rb_print_undef(rclass, oid, 0); } if (scope && (body->nd_noex & NOEX_MASK) != NOEX_PUBLIC) { - rb_print_undef(rclass, oid, (body->nd_noex & NOEX_MASK)); + rb_print_undef(rclass, oid, (int)(body->nd_noex & NOEX_MASK)); } klass = body->nd_clss; @@ -1362,7 +1376,7 @@ case NODE_CFUNC: if (body->nd_argc < 0) return -1; - return body->nd_argc; + return check_argc(body->nd_argc); case NODE_ZSUPER: return -1; case NODE_ATTRSET: @@ -1555,13 +1569,19 @@ bmcall(VALUE args, VALUE method) { volatile VALUE a; + VALUE ret; + int argc; if (CLASS_OF(args) != rb_cArray) { args = rb_ary_new3(1, args); + argc = 1; } - - a = args; - return rb_method_call(RARRAY_LEN(a), RARRAY_PTR(a), method); + else { + argc = check_argc(RARRAY_LEN(args)); + } + ret = rb_method_call(argc, RARRAY_PTR(args), method); + RB_GC_GUARD(a) = args; + return ret; } VALUE @@ -1698,7 +1718,8 @@ return arity; } else { - return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc); + return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), + RARRAY_PTR(passed), passed_proc); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/