[前][次][番号順一覧][スレッド一覧]

ruby-changes:25096

From: shyouhei <ko1@a...>
Date: Fri, 12 Oct 2012 13:06:01 +0900 (JST)
Subject: [ruby-changes:25096] shyouhei:r37148 (ruby_1_8_7): * error.c (name_err_to_s): we need not infect msg.

shyouhei	2012-10-12 13:05:35 +0900 (Fri, 12 Oct 2012)

  New Revision: 37148

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37148

  Log:
    * error.c (name_err_to_s): we need not infect msg.
    
    * test/ruby/test_exception.rb (TestException#test_exception_to_s_should_not_propagate_untrustedness): test for it.

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/error.c
    branches/ruby_1_8_7/test/ruby/test_exception.rb
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/error.c
===================================================================
--- ruby_1_8_7/error.c	(revision 37147)
+++ ruby_1_8_7/error.c	(revision 37148)
@@ -665,9 +665,6 @@
 
     if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
     StringValue(str);
-    if (str != mesg) {
-	OBJ_INFECT(str, mesg);
-    }
     return str;
 }
 
Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 37147)
+++ ruby_1_8_7/ChangeLog	(revision 37148)
@@ -1,3 +1,9 @@
+Fri Oct 12 12:25:15 2012  URABE Shyouhei  <shyouhei@r...>
+
+	* error.c (name_err_to_s): we need not infect msg.
+
+	* test/ruby/test_exception.rb (TestException#test_exception_to_s_should_not_propagate_untrustedness): test for it.
+
 Fri Jun 29 21:26:05 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval.c (stack_extend): prevent ALLOCA_N, which reserves a memory
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 37147)
+++ ruby_1_8_7/version.h	(revision 37148)
@@ -1,15 +1,15 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2012-06-29"
+#define RUBY_RELEASE_DATE "2012-10-12"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20120629
-#define RUBY_PATCHLEVEL 370
+#define RUBY_RELEASE_CODE 20121012
+#define RUBY_PATCHLEVEL 371
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2012
-#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 29
+#define RUBY_RELEASE_MONTH 10
+#define RUBY_RELEASE_DAY 12
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8_7/test/ruby/test_exception.rb
===================================================================
--- ruby_1_8_7/test/ruby/test_exception.rb	(revision 37147)
+++ ruby_1_8_7/test/ruby/test_exception.rb	(revision 37148)
@@ -204,6 +204,34 @@
     o.taint
     e = NameError.new(o)
     s = e.to_s
-    assert_equal(true, s.tainted?)
+    assert_equal(false, s.tainted?)
   end
+
+  def test_exception_to_s_should_not_propagate_untrustedness
+    favorite_lang = "Ruby"
+
+    for exc in [Exception, NameError]
+      assert_raise(SecurityError) do
+        lambda {
+          $SAFE = 4
+          exc.new(favorite_lang).to_s
+          favorite_lang.replace("Python")
+        }.call
+      end
+    end
+
+    assert_raise(SecurityError) do
+      lambda {
+        $SAFE = 4
+        o = Object.new
+        (class << o; self; end).send(:define_method, :to_str) {
+          favorite_lang
+        }
+        NameError.new(o).to_s
+        favorite_lang.replace("Python")
+      }.call
+    end
+
+    assert_equal("Ruby", favorite_lang)
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]