ruby-changes:11758
From: yugui <ko1@a...>
Date: Tue, 12 May 2009 00:07:26 +0900 (JST)
Subject: [ruby-changes:11758] Ruby:r23405 (ruby_1_9_1): * ext/dl/dl.c (rb_dlhandle_initialize): prohibits DL::dlopen
yugui 2009-05-12 00:07:10 +0900 (Tue, 12 May 2009) New Revision: 23405 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23405 Log: * ext/dl/dl.c (rb_dlhandle_initialize): prohibits DL::dlopen with a tainted name of library. Patch by sheepman <sheepman AT sheepman.sakura.ne.jp>. * ext/dl/dl.c (rb_dlhandle_sym): ditto Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/ext/dl/handle.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 23404) +++ ruby_1_9_1/ChangeLog (revision 23405) @@ -1,3 +1,11 @@ +Mon May 11 23:14:06 2009 Yuki Sonoda (Yugui) <yugui@y...> + + * ext/dl/dl.c (rb_dlhandle_initialize): prohibits DL::dlopen + with a tainted name of library. + Patch by sheepman <sheepman AT sheepman.sakura.ne.jp>. + + * ext/dl/dl.c (rb_dlhandle_sym): ditto + Mon May 11 22:33:46 2009 Yuki Sonoda (Yugui) <yugui@y...> * ext/dl/lib/dl/func.rb (DL::Function#call): prevents Index: ruby_1_9_1/ext/dl/handle.c =================================================================== --- ruby_1_9_1/ext/dl/handle.c (revision 23404) +++ ruby_1_9_1/ext/dl/handle.c (revision 23405) @@ -5,6 +5,8 @@ #include <ruby.h> #include "dl.h" +#define SafeStringValuePtr(v) (rb_string_value(&v), rb_check_safe_obj(v), RSTRING_PTR(v)) + VALUE rb_cDLHandle; void @@ -56,11 +58,11 @@ cflag = RTLD_LAZY | RTLD_GLOBAL; break; case 1: - clib = NIL_P(lib) ? NULL : StringValuePtr(lib); + clib = NIL_P(lib) ? NULL : SafeStringValuePtr(lib); cflag = RTLD_LAZY | RTLD_GLOBAL; break; case 2: - clib = NIL_P(lib) ? NULL : StringValuePtr(lib); + clib = NIL_P(lib) ? NULL : SafeStringValuePtr(lib); cflag = NUM2INT(flag); break; default: @@ -140,7 +142,7 @@ rb_secure(2); - name = StringValuePtr(sym); + name = SafeStringValuePtr(sym); Data_Get_Struct(self, struct dl_handle, dlhandle); if( ! dlhandle->open ){ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/