Skip to content

Commit 2ac236d

Browse files
committed
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@37148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent e48d99f commit 2ac236d

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Fri Oct 12 12:25:15 2012 URABE Shyouhei <shyouhei@ruby-lang.org>
2+
3+
* error.c (name_err_to_s): we need not infect msg.
4+
5+
* test/ruby/test_exception.rb (TestException#test_exception_to_s_should_not_propagate_untrustedness): test for it.
6+
17
Fri Jun 29 21:26:05 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
28

39
* eval.c (stack_extend): prevent ALLOCA_N, which reserves a memory

error.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,6 @@ name_err_to_s(exc)
665665

666666
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
667667
StringValue(str);
668-
if (str != mesg) {
669-
OBJ_INFECT(str, mesg);
670-
}
671668
return str;
672669
}
673670

test/ruby/test_exception.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,34 @@ def o.to_str
204204
o.taint
205205
e = NameError.new(o)
206206
s = e.to_s
207-
assert_equal(true, s.tainted?)
207+
assert_equal(false, s.tainted?)
208+
end
209+
210+
def test_exception_to_s_should_not_propagate_untrustedness
211+
favorite_lang = "Ruby"
212+
213+
for exc in [Exception, NameError]
214+
assert_raise(SecurityError) do
215+
lambda {
216+
$SAFE = 4
217+
exc.new(favorite_lang).to_s
218+
favorite_lang.replace("Python")
219+
}.call
220+
end
221+
end
222+
223+
assert_raise(SecurityError) do
224+
lambda {
225+
$SAFE = 4
226+
o = Object.new
227+
(class << o; self; end).send(:define_method, :to_str) {
228+
favorite_lang
229+
}
230+
NameError.new(o).to_s
231+
favorite_lang.replace("Python")
232+
}.call
233+
end
234+
235+
assert_equal("Ruby", favorite_lang)
208236
end
209237
end

version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#define RUBY_VERSION "1.8.7"
2-
#define RUBY_RELEASE_DATE "2012-06-29"
2+
#define RUBY_RELEASE_DATE "2012-10-12"
33
#define RUBY_VERSION_CODE 187
4-
#define RUBY_RELEASE_CODE 20120629
5-
#define RUBY_PATCHLEVEL 370
4+
#define RUBY_RELEASE_CODE 20121012
5+
#define RUBY_PATCHLEVEL 371
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8
99
#define RUBY_VERSION_TEENY 7
1010
#define RUBY_RELEASE_YEAR 2012
11-
#define RUBY_RELEASE_MONTH 6
12-
#define RUBY_RELEASE_DAY 29
11+
#define RUBY_RELEASE_MONTH 10
12+
#define RUBY_RELEASE_DAY 12
1313

1414
#ifdef RUBY_EXTERN
1515
RUBY_EXTERN const char ruby_version[];

0 commit comments

Comments
 (0)