Skip to content

Commit 11b262e

Browse files
committed
merge revision(s) 15645:15647:
* bignum.c (big2str_find_n1): check integer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 4d7f100 commit 11b262e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Sun Jun 15 19:54:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* bignum.c (big2str_find_n1): check integer overflow.
4+
15
Sun Jun 15 19:52:20 2008 Tanaka Akira <akr@fsij.org>
26

37
* gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]

bignum.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ rb_big2str0(x, base, trim)
652652
if (BIGZEROP(x)) {
653653
return rb_str_new2("0");
654654
}
655+
if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
656+
rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
657+
}
655658
j = SIZEOF_BDIGITS*CHAR_BIT*i;
656659
switch (base) {
657660
case 2: break;

test/ruby/test_bignum.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,12 @@ def test_shift
8484
shift_test(-4518325415524767873)
8585
shift_test(-0xfffffffffffffffff)
8686
end
87+
88+
def test_too_big_to_s
89+
if (big = 2**31-1).is_a?(Fixnum)
90+
return
91+
end
92+
e = assert_raise(RangeError) {(1 << big).to_s}
93+
assert_match(/too big to convert/, e.message)
94+
end
8795
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define RUBY_RELEASE_DATE "2008-06-15"
33
#define RUBY_VERSION_CODE 186
44
#define RUBY_RELEASE_CODE 20080615
5-
#define RUBY_PATCHLEVEL 183
5+
#define RUBY_PATCHLEVEL 184
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8

0 commit comments

Comments
 (0)