ruby-changes:40995
From: nobu <ko1@a...>
Date: Sun, 13 Dec 2015 18:19:41 +0900 (JST)
Subject: [ruby-changes:40995] nobu:r53074 (trunk): win32ole.c: check argument type
nobu 2015-12-13 18:19:20 +0900 (Sun, 13 Dec 2015) New Revision: 53074 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53074 Log: win32ole.c: check argument type * ext/win32ole/win32ole.c (ole_vstr2wc): check argument type, vstr must be a String here. reported by Marcin 'Icewall' Noga of Cisco Talos. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c trunk/test/win32ole/test_win32ole.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53073) +++ ChangeLog (revision 53074) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 13 18:19:20 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/win32ole/win32ole.c (ole_vstr2wc): check argument type, vstr + must be a String here. reported by Marcin 'Icewall' Noga of + Cisco Talos. + Sun Dec 13 16:41:01 2015 Nobuyoshi Nakada <nobu@r...> * configure.in (BOOTSTRAPRUBY): make BASERUBY full path before Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 53073) +++ ext/win32ole/win32ole.c (revision 53074) @@ -860,6 +860,11 @@ ole_vstr2wc(VALUE vstr) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L860 LPWSTR pw; st_data_t data; struct st_table *tbl = DATA_PTR(enc2cp_hash); + + /* do not type-conversion here to prevent from other arguments + * changing (if exist) */ + Check_Type(vstr, T_STRING); + enc = rb_enc_get(vstr); if (st_lookup(tbl, (VALUE)enc | FIXNUM_FLAG, &data)) { Index: test/win32ole/test_win32ole.rb =================================================================== --- test/win32ole/test_win32ole.rb (revision 53073) +++ test/win32ole/test_win32ole.rb (revision 53074) @@ -312,6 +312,9 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L312 assert_raise(ArgumentError) { shell.ole_query_interface } + assert_raise(TypeError) { + shell.ole_query_interface(0x11223344) + } shell2 = shell.ole_query_interface('{A4C6892C-3BA9-11D2-9DEA-00C04FB16162}') assert_instance_of(WIN32OLE, shell2) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/