Skip to content

Commit 4600cf7

Browse files
committed
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 7269e3d commit 4600cf7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Mon May 11 23:14:06 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
2+
3+
* ext/dl/dl.c (rb_dlhandle_initialize): prohibits DL::dlopen
4+
with a tainted name of library.
5+
Patch by sheepman <sheepman AT sheepman.sakura.ne.jp>.
6+
7+
* ext/dl/dl.c (rb_dlhandle_sym): ditto
8+
19
Mon May 11 22:33:46 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
210

311
* ext/dl/lib/dl/func.rb (DL::Function#call): prevents

ext/dl/handle.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <ruby.h>
66
#include "dl.h"
77

8+
#define SafeStringValuePtr(v) (rb_string_value(&v), rb_check_safe_obj(v), RSTRING_PTR(v))
9+
810
VALUE rb_cDLHandle;
911

1012
void
@@ -56,11 +58,11 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
5658
cflag = RTLD_LAZY | RTLD_GLOBAL;
5759
break;
5860
case 1:
59-
clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
61+
clib = NIL_P(lib) ? NULL : SafeStringValuePtr(lib);
6062
cflag = RTLD_LAZY | RTLD_GLOBAL;
6163
break;
6264
case 2:
63-
clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
65+
clib = NIL_P(lib) ? NULL : SafeStringValuePtr(lib);
6466
cflag = NUM2INT(flag);
6567
break;
6668
default:
@@ -140,7 +142,7 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
140142

141143
rb_secure(2);
142144

143-
name = StringValuePtr(sym);
145+
name = SafeStringValuePtr(sym);
144146

145147
Data_Get_Struct(self, struct dl_handle, dlhandle);
146148
if( ! dlhandle->open ){

0 commit comments

Comments
 (0)