diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | ext/openssl/ossl_bn.c | 2 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_dh.c | 6 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_dsa.c | 2 | ||||
-rw-r--r-- | ext/openssl/ossl_rand.c | 16 | ||||
-rw-r--r-- | ext/openssl/ossl_x509store.c | 2 |
6 files changed, 28 insertions, 12 deletions
@@ -1,3 +1,15 @@ +Fri May 30 02:35:00 2008 Akinori MUSHA <[email protected]> + + * ext/openssl/ossl_bn.c (ossl_bn_s_rand, ossl_bn_s_pseudo_rand), + ext/openssl/ossl_pkey_dh.c (ossl_dh_s_generate) + (ossl_dh_initialize), + ext/openssl/ossl_pkey_dsa.c (ossl_dsa_s_generate), + ext/openssl/ossl_rand.c (ossl_rand_bytes) + (ossl_rand_pseudo_bytes, ossl_rand_egd_bytes), + ext/openssl/ossl_x509store.c (ossl_x509stctx_set_error): Do not + use FIX2INT() without checking the value type. Use NUM2INT() + instead; found by akr in [ruby-dev:34890]. + Fri May 30 02:08:20 2008 Yusuke Endoh <[email protected]> * signal.c (esignal_init): handle a non-integer argument correctly, diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index 83d2bf43c7..8f0e2edcfd 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -515,7 +515,7 @@ BIGNUM_SELF_SHIFT(rshift); bottom = (odd == Qtrue) ? 1 : 0; \ /* FALLTHROUGH */ \ case 2: \ - top = FIX2INT(fill); \ + top = NUM2INT(fill); \ } \ b = NUM2INT(bits); \ if (!(result = BN_new())) { \ diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c index bd4cc756e7..02c3d99ed8 100644 --- a/ext/openssl/ossl_pkey_dh.c +++ b/ext/openssl/ossl_pkey_dh.c @@ -116,9 +116,9 @@ ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass) VALUE size, gen, obj; if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) { - g = FIX2INT(gen); + g = NUM2INT(gen); } - dh = dh_generate(FIX2INT(size), g); + dh = dh_generate(NUM2INT(size), g); obj = dh_instance(klass, dh); if (obj == Qfalse) { DH_free(dh); @@ -158,7 +158,7 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self) } else if (FIXNUM_P(arg)) { if (!NIL_P(gen)) { - g = FIX2INT(gen); + g = NUM2INT(gen); } if (!(dh = dh_generate(FIX2INT(arg), g))) { ossl_raise(eDHError, NULL); diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c index 78b60c6edf..d9c7fcbe78 100644 --- a/ext/openssl/ossl_pkey_dsa.c +++ b/ext/openssl/ossl_pkey_dsa.c @@ -110,7 +110,7 @@ dsa_generate(int size) static VALUE ossl_dsa_s_generate(VALUE klass, VALUE size) { - DSA *dsa = dsa_generate(FIX2INT(size)); /* err handled by dsa_instance */ + DSA *dsa = dsa_generate(NUM2INT(size)); /* err handled by dsa_instance */ VALUE obj = dsa_instance(klass, dsa); if (obj == Qfalse) { diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c index c22a7357b0..d9c1a7f34f 100644 --- a/ext/openssl/ossl_rand.c +++ b/ext/openssl/ossl_rand.c @@ -96,9 +96,10 @@ static VALUE ossl_rand_bytes(VALUE self, VALUE len) { VALUE str; - - str = rb_str_new(0, FIX2INT(len)); - if (!RAND_bytes(RSTRING_PTR(str), FIX2INT(len))) { + long n = NUM2INT(len); + + str = rb_str_new(0, n); + if (!RAND_bytes(RSTRING_PTR(str), n)) { ossl_raise(eRandomError, NULL); } @@ -114,9 +115,10 @@ static VALUE ossl_rand_pseudo_bytes(VALUE self, VALUE len) { VALUE str; + long n = NUM2INT(len); - str = rb_str_new(0, FIX2INT(len)); - if (!RAND_pseudo_bytes(RSTRING_PTR(str), FIX2INT(len))) { + str = rb_str_new(0, n); + if (!RAND_pseudo_bytes(RSTRING_PTR(str), n)) { ossl_raise(eRandomError, NULL); } @@ -147,9 +149,11 @@ ossl_rand_egd(VALUE self, VALUE filename) static VALUE ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len) { + long n = NUM2INT(len); + SafeStringValue(filename); - if (!RAND_egd_bytes(RSTRING_PTR(filename), FIX2INT(len))) { + if (!RAND_egd_bytes(RSTRING_PTR(filename), n)) { ossl_raise(eRandomError, NULL); } return Qtrue; diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c index 24a6625ee4..769ce8a91a 100644 --- a/ext/openssl/ossl_x509store.c +++ b/ext/openssl/ossl_x509store.c @@ -458,7 +458,7 @@ ossl_x509stctx_set_error(VALUE self, VALUE err) X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); - X509_STORE_CTX_set_error(ctx, FIX2INT(err)); + X509_STORE_CTX_set_error(ctx, NUM2INT(err)); return err; } |