aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_bn.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 07:57:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 07:57:17 +0000
commitadb492406ce489cae104e743bbd77684fa67da48 (patch)
tree774459733153135dca1c6e9f90b31c57a22e6f79 /ext/openssl/ossl_bn.c
parent91fb5bc88992dd7f4edae20934f814f052b516d6 (diff)
downloadruby-adb492406ce489cae104e743bbd77684fa67da48.tar.gz
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
Diffstat (limited to 'ext/openssl/ossl_bn.c')
-rw-r--r--ext/openssl/ossl_bn.c4
1 files changed, 2 insertions, 2 deletions
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);