summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c3
-rw-r--r--test/ruby/test_bignum.rb9
-rw-r--r--version.h8
4 files changed, 20 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ef045835e7..46a3ca20b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Mar 1 02:35:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * bignum.c (big2str_find_n1): check integer overflow.
+
Tue Feb 26 16:06:00 2008 Technorama Ltd. <oss-ruby@technorama.net>
* ext/openssl/ossl_pkey_{ec,dh,dsa,rsa}.c: Remove useless warnings.
diff --git a/bignum.c b/bignum.c
index 9a5bd0c228..6d1b5547a5 100644
--- a/bignum.c
+++ b/bignum.c
@@ -676,6 +676,9 @@ rb_big2str0(x, base, trim)
if (BIGZEROP(x)) {
return rb_str_new2("0");
}
+ if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
+ }
j = SIZEOF_BDIGITS*CHAR_BIT*i;
switch (base) {
case 2: break;
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 48e8d9a92c..bfc47784f0 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -95,4 +95,13 @@ class TestBignum < Test::Unit::TestCase
assert_equal("1777777777777777777777" ,18446744073709551615.to_s(8))
assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8))
end
+
+ def test_too_big_to_s
+ i = 32
+ while (big = 2**(i-1)-1).is_a?(Fixnum)
+ i *= 2
+ end
+ e = assert_raise(RangeError) {(1 << big).to_s}
+ assert_match(/too big to convert/, e.message)
+ end
end
diff --git a/version.h b/version.h
index 4c1dddeb53..8e20e16819 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.6"
-#define RUBY_RELEASE_DATE "2008-02-26"
+#define RUBY_RELEASE_DATE "2008-03-01"
#define RUBY_VERSION_CODE 186
-#define RUBY_RELEASE_CODE 20080226
+#define RUBY_RELEASE_CODE 20080301
#define RUBY_PATCHLEVEL 5000
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_YEAR 2008
-#define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 26
+#define RUBY_RELEASE_MONTH 3
+#define RUBY_RELEASE_DAY 1
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];