mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
91fb5bc889
commit
adb492406c
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue