From adb492406ce489cae104e743bbd77684fa67da48 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 Apr 2013 07:57:17 +0000 Subject: ext/openssl/ossl_bn.c: fix implicit conversion * ext/openssl/ossl_bn.c (ossl_bn_initialize): fix precision loss by implicit conversion. * ext/openssl/ossl_bn.c (ossl_bn_initialize): check Bignum overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_bn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/openssl/ossl_bn.c') diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index f04daec568..4e9734ee22 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -125,7 +125,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) long i; unsigned char *bin = (unsigned char*)ALLOC_N(long, 1); long n = FIX2LONG(str); - unsigned long un = abs(n); + unsigned long un = labs(n); for (i = sizeof(VALUE) - 1; 0 <= i; i--) { bin[i] = un&0xff; @@ -153,7 +153,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) } GetBN(self, bn); - if (!BN_bin2bn(bin, sizeof(BDIGIT)*RBIGNUM_LEN(str), bn)) { + if (!BN_bin2bn(bin, (int)sizeof(BDIGIT)*RBIGNUM_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } if (!RBIGNUM_SIGN(str)) BN_set_negative(bn, 1); -- cgit v1.2.3