Issue #5279 has been updated by Kenta Murata.


???rb_require_safe ??膃2綣???違??0???羝<??????????????????????????????с??????
???transcoder ??筝??т??????????? safe level ???0???祉??????????????????????????????с??????с??????????????
----------------------------------------
Bug #5279: $SAFE???3篁ヤ?????????String#encode???SecurityError?????榊?????????????宴?若?鴻????????
http://redmine.ruby-lang.org/issues/5279

Author: Shota Fukumori
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.4dev (2011-09-05 trunk 33195) [x86_64-darwin11.1.0] 


sora_h??с??鐚?

twitter
??? @hsbt ??????????????????????????荐???c?????????ц??祉?????帥?障?????:
http://twitter.com/#!/hsbt/status/110700488667832320

茯炊?祉????????????鐚???????????String#encode???????????require???????????
??祉?若?????????3???????????????吾?с??????羆????????????????э??rb_require_safe??羝???String???羆???????????????????鐚?
rb_require???SecurityError?????榊???????障??鐚?

????э??篁ヤ?????翫?????SecurityError?????榊???????障?????鐚?

    $SAFE = 3
    "a".encode("UTF-16")

篁ヤ?????翫?????榊???????障?????鐚?

    "a".encode("UTF-16")
    $SAFE = 3
    "a".encode("UTF-16")

?????????篆罩????????????????????吾?????帥?障????????(?????宴???????絨??莢???篁????)鐚?
????????????rb_require_safe??膃篋?綣???違??0???羝<???????????????????篆???????????障?????鐚?
?????????祉??ャ?????e???????????э???????????????c????????潟????????鐚??????????????????????
??????????篆罩??????????????????????????潟??????????????????????????障??鐚?

篁ヤ??patch

diff --git a/ChangeLog b/ChangeLog
index a16e823..07f76a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep  6 08:56:06 2011  Shota Fukumori  <sorah / tubusu.net>
+
+       * transcode.c: Use rb_require_safe() to load transcoder.
+         Because if $SAFE is higher than 3, rb_require() raises SecurityError.
+
 Mon Sep  5 20:59:30 2011  CHIKANAGA Tomoyuki  <nagachika00 / gmail.com>

        * insns.def: change encoding pragma for emacs (shift_jis to utf-8).
diff --git a/transcode.c b/transcode.c
index 2c188b6..0651aec 100644
--- a/transcode.c
+++ b/transcode.c
@@ -375,7 +375,7 @@ load_transcoder_entry(transcoder_entry_t *entry)
             return NULL;
         memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1);
         memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len + 1);
-        if (!rb_require(path))
+        if (!rb_require_safe(rb_str_new2(path), 0))
             return NULL;
     }


-- 
http://redmine.ruby-lang.org