diff options
author | technorama <technorama@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-26 07:07:26 +0000 |
---|---|---|
committer | technorama <technorama@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-26 07:07:26 +0000 |
commit | 161b45f59ccb1d220a0b7741d4d3e1be6134944a (patch) | |
tree | daa8a079a6ab8d7cc9202586b23b0a78c12da4f5 /ext | |
parent | 43b1b0e16a6ced5ba337a0f3f120f5d21f9abf8d (diff) | |
download | bundler-161b45f59ccb1d220a0b7741d4d3e1be6134944a.tar.gz |
* ext/openssl/ossl_{ec,dh,dsa,rsa}.c: Remove useless warnings.
* ext/openssl/ossl_asn1.c: Simplify code.
* ext/openssl/ossl_ssl_session.c Fix compiler warnings.
Undefine #id if SSL_SESSION_get_id is not supported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_asn1.c | 33 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_dh.c | 2 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_dsa.c | 4 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_ec.c | 3 | ||||
-rw-r--r-- | ext/openssl/ossl_pkey_rsa.c | 2 | ||||
-rw-r--r-- | ext/openssl/ossl_ssl_session.c | 6 |
6 files changed, 17 insertions, 33 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index 8ceea95021..b348c03a73 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -347,16 +347,11 @@ decode_bstr(unsigned char* der, int length, long *unused_bits) if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length))) ossl_raise(eASN1Error, NULL); len = bstr->length; - if(!(buf = OPENSSL_malloc(len))){ - ASN1_BIT_STRING_free(bstr); - ossl_raise(eASN1Error, NULL); - } *unused_bits = 0; if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT) *unused_bits = bstr->flags & 0x07; - memcpy(buf, bstr->data, len); + ret = rb_str_new(bstr->data, len); ASN1_BIT_STRING_free(bstr); - ret = ossl_buf2str(buf, len); return ret; } @@ -925,7 +920,7 @@ ossl_asn1prim_to_der(VALUE self) { ASN1_TYPE *asn1; int tn, tc, explicit; - long length, reallen; + long len, reallen; unsigned char *buf, *p; VALUE str; @@ -934,26 +929,24 @@ ossl_asn1prim_to_der(VALUE self) explicit = ossl_asn1_is_explicit(self); asn1 = ossl_asn1_get_asn1type(self); - length = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn); - if(!(buf = OPENSSL_malloc(length))){ + len = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn); + if(!(buf = OPENSSL_malloc(len))){ ossl_ASN1_TYPE_free(asn1); ossl_raise(eASN1Error, "cannot alloc buffer"); } p = buf; - if(tc == V_ASN1_UNIVERSAL) ossl_i2d_ASN1_TYPE(asn1, &p); - else{ - if(explicit){ - ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc); - ossl_i2d_ASN1_TYPE(asn1, &p); - } - else{ - ossl_i2d_ASN1_TYPE(asn1, &p); - *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED); - } + if (tc == V_ASN1_UNIVERSAL) { + ossl_i2d_ASN1_TYPE(asn1, &p); + } else if (explicit) { + ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc); + ossl_i2d_ASN1_TYPE(asn1, &p); + } else { + ossl_i2d_ASN1_TYPE(asn1, &p); + *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED); } ossl_ASN1_TYPE_free(asn1); reallen = p - buf; - assert(reallen <= length); + assert(reallen <= len); str = ossl_buf2str(buf, reallen); /* buf will be free in ossl_buf2str */ return str; diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c index a6924a6bb8..bd4cc756e7 100644 --- a/ext/openssl/ossl_pkey_dh.c +++ b/ext/openssl/ossl_pkey_dh.c @@ -524,11 +524,9 @@ Init_ossl_dh() } #else /* defined NO_DH */ -# warning >>> OpenSSL is compiled without DH support <<< void Init_ossl_dh() { - rb_warning("OpenSSL is compiled without DH support"); } #endif /* NO_DH */ diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c index 95dc426366..78b60c6edf 100644 --- a/ext/openssl/ossl_pkey_dsa.c +++ b/ext/openssl/ossl_pkey_dsa.c @@ -477,12 +477,8 @@ Init_ossl_dsa() } #else /* defined NO_DSA */ -# warning >>> OpenSSL is compiled without DSA support <<< - void Init_ossl_dsa() { - rb_warning("OpenSSL is compiled without DSA support"); } - #endif /* NO_DSA */ diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c index c3a15e722b..210054121d 100644 --- a/ext/openssl/ossl_pkey_ec.c +++ b/ext/openssl/ossl_pkey_ec.c @@ -1576,10 +1576,7 @@ void Init_ossl_ec() } #else /* defined NO_EC */ -# warning >>> OpenSSL is compiled without EC support <<< - void Init_ossl_ec() { } - #endif /* NO_EC */ diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c index 4a690a7cb5..9ac69e7ded 100644 --- a/ext/openssl/ossl_pkey_rsa.c +++ b/ext/openssl/ossl_pkey_rsa.c @@ -585,11 +585,9 @@ Init_ossl_rsa() } #else /* defined NO_RSA */ -# warning >>> OpenSSL is compiled without RSA support <<< void Init_ossl_rsa() { - rb_warning("OpenSSL is compiled without RSA support"); } #endif /* NO_RSA */ diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c index b347f2c1b2..82de3efbe3 100644 --- a/ext/openssl/ossl_ssl_session.c +++ b/ext/openssl/ossl_ssl_session.c @@ -174,7 +174,7 @@ static VALUE ossl_ssl_session_get_id(VALUE self) p = SSL_SESSION_get_id(ctx, &i); - return rb_str_new(p, i); + return rb_str_new((const char *) p, i); } #endif @@ -200,7 +200,7 @@ static VALUE ossl_ssl_session_to_der(VALUE self) else if (len >= sizeof(buf)) ossl_raise(eSSLSession, "i2d_SSL_SESSION too large"); - return rb_str_new(p, len); + return rb_str_new((const char *) p, len); } /* @@ -289,6 +289,8 @@ void Init_ossl_ssl_session(void) #ifdef HAVE_SSL_SESSION_GET_ID rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0); +#else + rb_undef_method(cSSLSession, "id"); #endif rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0); rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0); |