Project

General

Profile

Bug #3816

OpenSSL::BN#prime?の引数の取り扱いがおかしい

Added by naruse (Yui NARUSE) almost 9 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-09-10 trunk 29213) [x86_64-freebsd8.1]
Backport:
[ruby-dev:42225]

Description

=begin
OpenSSL::BN#prime?を引数なしで呼ぶと以下の通り例外が出ます。

irb(main):001:0> require'openssl'=> trueirb(main):002:0> OpenSSL::BN.new("461166461445805738999").prime?
TypeError: no implicit conversion from nil to integer
from (irb):2:in prime?'
from (irb):2
from /home/naruse/local/ruby_1_9_2/bin/irb:12:in
'

コードを見るに、rb_scan_args の引数との比較が誤っているように見えるので、引数ありでもおかしいでしょう。
以下の変更で直ります。

diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index bec5135..6adc59f 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -669,7 +669,7 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
VALUE vchecks;
int checks = BN_prime_checks;

  • if (rb_scan_args(argc, argv, "01", &vchecks) == 0) {
  • if (rb_scan_args(argc, argv, "01", &vchecks) == 1) { checks = NUM2INT(vchecks); } GetBN(self, bn); =end

History

#1

Updated by naruse (Yui NARUSE) almost 9 years ago

  • Status changed from Assigned to Closed

=begin
fixed at r29237
=end

Also available in: Atom PDF