ruby-changes:28132
From: nobu <ko1@a...>
Date: Mon, 8 Apr 2013 17:19:43 +0900 (JST)
Subject: [ruby-changes:28132] nobu:r40184 (trunk): win32ole.c: check arity
nobu 2013-04-08 17:19:32 +0900 (Mon, 08 Apr 2013) New Revision: 40184 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40184 Log: win32ole.c: check arity * ext/win32ole/win32ole.c (fole_missing): should check actual argument count before accessing. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c trunk/test/win32ole/test_win32ole.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 40183) +++ ChangeLog (revision 40184) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Apr 8 17:19:28 2013 Nobuyoshi Nakada <nobu@r...> + + * ext/win32ole/win32ole.c (fole_missing): should check actual argument + count before accessing. + Mon Apr 8 16:03:55 2013 Yuki Yugui Sonoda <yugui@g...> Fixes a build failure of ext/ripper/ripper.c on building out of place. Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 40183) +++ ext/win32ole/win32ole.c (revision 40184) @@ -4078,6 +4078,7 @@ fole_missing(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L4078 ID id; const char* mname; int n; + rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); id = rb_to_id(argv[0]); mname = rb_id2name(id); if(!mname) { @@ -4085,6 +4086,7 @@ fole_missing(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L4086 } n = strlen(mname); if(mname[n-1] == '=') { + rb_check_arity(argc, 2, 2); argv[0] = rb_enc_str_new(mname, n-1, cWIN32OLE_enc); return ole_propertyput(self, argv[0], argv[1]); Index: test/win32ole/test_win32ole.rb =================================================================== --- test/win32ole/test_win32ole.rb (revision 40183) +++ test/win32ole/test_win32ole.rb (revision 40184) @@ -495,6 +495,13 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L495 def test_const_LOCALE_USER_DEFAULT assert_equal(0x0400, WIN32OLE::LOCALE_USER_DEFAULT); end + + def test_method_missing + assert_raise(ArgumentError) {@dict1.method_missing} + assert_raise(TypeError) {@dict1.method_missing(1)} + assert_raise(ArgumentError) {@dict1.method_missing("foo=")} + assert_raise(ArgumentError) {@dict1.method_missing("foo=", 1, 2)} + end end # test of subclass of WIN32OLE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/