summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-26 17:11:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-26 17:11:12 +0000
commit40465862bdb23bddfe1d8b52f21962a4ccb9208a (patch)
tree27b85c6c7934833a436f56e7adb747b0e61ea1f5 /bignum.c
parent9e159579e0a074e5723c4eec4381ea56979b5b95 (diff)
* io.c (next_argv): warn always for stdin on inplace edit mode.
* io.c (read_all): need to check string value. * io.c (argf_read): allow ARGF.read(nil). [ruby-dev:22433] * io.c (rb_f_backquote): need not to check nil result. [ruby-core:02078] * io.c (rb_io_getline): should return nil when read_all gives empty string, even when nil rs is specified. [ruby-core:02077] * pack.c (pack_pack): add sign check for 'i', and 'l'. [ruby-dev:22427] * bignum.c (rb_quad_pack): add range check for 'quad int'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index 5089bff..6155ec7 100644
--- a/bignum.c
+++ b/bignum.c
@@ -203,6 +203,8 @@ rb_quad_pack(buf, val)
long len = RBIGNUM(val)->len;
BDIGIT *ds;
+ if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
+ rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
ds = BDIGITS(val);
q = 0;
while (len--) {
@@ -272,7 +274,9 @@ rb_quad_pack(buf, val)
val = rb_int2big(FIX2LONG(val));
}
len = RBIGNUM(val)->len * SIZEOF_BDIGITS;
- if (len > QUAD_SIZE) len = QUAD_SIZE;
+ if (len > QUAD_SIZE) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
+ }
memcpy(buf, (char*)BDIGITS(val), len);
if (!RBIGNUM(val)->sign) {
len = QUAD_SIZE;
@@ -759,10 +763,10 @@ long
rb_big2long(x)
VALUE x;
{
- unsigned long num = big2ulong(x, "int");
+ unsigned long num = big2ulong(x, "long");
if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `int'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
}
if (!RBIGNUM(x)->sign) return -(long)num;
return num;