ruby-changes:28411
From: nobu <ko1@a...>
Date: Thu, 25 Apr 2013 16:57:23 +0900 (JST)
Subject: [ruby-changes:28411] nobu:r40463 (trunk): ext/openssl/ossl_bn.c: fix implicit conversion
nobu 2013-04-25 16:57:17 +0900 (Thu, 25 Apr 2013) New Revision: 40463 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40463 Log: 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. Modified files: trunk/ext/openssl/ossl_bn.c Index: ext/openssl/ossl_bn.c =================================================================== --- ext/openssl/ossl_bn.c (revision 40462) +++ ext/openssl/ossl_bn.c (revision 40463) @@ -125,7 +125,7 @@ ossl_bn_initialize(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_bn.c#L125 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 https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_bn.c#L153 } 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/