diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-02-23 07:27:42 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-02-23 07:27:42 +0000 |
commit | 59dd8c5696d83aff78c506d2a161ea4ffb404088 (patch) | |
tree | 4122e0c64fd7117dfdc776f013fb1e487d227b4f | |
parent | 447afde226aac7461d8a549ea8aae5763b0e3124 (diff) | |
download | ruby-openssl-history-59dd8c5696d83aff78c506d2a161ea4ffb404088.tar.gz |
* More benevolent checks (Check_SafeStr(x) -> Check_Type(x, T_STRING)
(where we don't care)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ossl_bn.c | 6 | ||||
-rw-r--r-- | ossl_cipher.c | 10 | ||||
-rw-r--r-- | ossl_config.c | 6 | ||||
-rw-r--r-- | ossl_digest.c | 4 | ||||
-rw-r--r-- | ossl_hmac.c | 4 | ||||
-rw-r--r-- | ossl_ns_spki.c | 3 | ||||
-rw-r--r-- | ossl_pkcs7.c | 7 | ||||
-rw-r--r-- | ossl_pkey_dh.c | 2 | ||||
-rw-r--r-- | ossl_pkey_dsa.c | 12 | ||||
-rw-r--r-- | ossl_pkey_rsa.c | 16 | ||||
-rw-r--r-- | ossl_rand.c | 2 | ||||
-rw-r--r-- | ossl_x509.c | 1 | ||||
-rw-r--r-- | ossl_x509attr.c | 4 | ||||
-rw-r--r-- | ossl_x509crl.c | 1 | ||||
-rw-r--r-- | ossl_x509ext.c | 4 | ||||
-rw-r--r-- | ossl_x509name.c | 4 | ||||
-rw-r--r-- | ossl_x509req.c | 1 |
18 files changed, 45 insertions, 46 deletions
@@ -4,6 +4,10 @@ Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz> All rights reserved. $Log$ +Revision 1.32 2002/02/23 07:28:00 majkl + * More benevolent checks (Check_SafeStr(x) -> Check_Type(x, T_STRING) + (where we don't care) + Revision 1.31 2002/02/20 08:43:54 majkl * Fixed some memory leaks @@ -84,7 +84,7 @@ ossl_bn_s_new(int argc, VALUE *argv, VALUE klass) { \ BIGNUM *bn = NULL; \ \ - Check_SafeStr(str); \ + Check_Type(str, T_STRING); \ \ GetBN(self, bn); \ \ @@ -102,7 +102,7 @@ BIGNUM_FROM(mpi); { \ BIGNUM *bn = NULL; \ \ - Check_SafeStr(str); \ + Check_Type(str, T_STRING); \ \ GetBN(self, bn); \ \ @@ -510,7 +510,7 @@ ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass) if (!NIL_P(vadd)) { if (NIL_P(vrem)) - rb_raise(rb_eArgError, "if add is specified, rem must be also given"); + rb_raise(rb_eArgError, "if ADD is specified, REM must be also given"); OSSL_Check_Type(vadd, cBN); OSSL_Check_Type(vrem, cBN); diff --git a/ossl_cipher.c b/ossl_cipher.c index 22fc5e2..35cf886 100644 --- a/ossl_cipher.c +++ b/ossl_cipher.c @@ -116,7 +116,7 @@ ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "11", &pass, &init_v); - Check_SafeStr(pass); + Check_Type(pass, T_STRING); if (NIL_P(init_v)) { /* @@ -131,7 +131,7 @@ ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self) } */ } else { - Check_SafeStr(init_v); + Check_Type(init_v, T_STRING); memcpy(iv, RSTRING(init_v)->ptr, sizeof(iv)); } EVP_CIPHER_CTX_init(ciphp->ctx); @@ -157,7 +157,7 @@ ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "11", &pass, &init_v); - Check_SafeStr(pass); + Check_Type(pass, T_STRING); if (NIL_P(init_v)) { /* @@ -166,7 +166,7 @@ ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self) */ memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv)); } else { - Check_SafeStr(init_v); + Check_Type(init_v, T_STRING); memcpy(iv, RSTRING(init_v)->ptr, sizeof(iv)); } EVP_CIPHER_CTX_init(ciphp->ctx); @@ -193,7 +193,7 @@ ossl_cipher_update(VALUE self, VALUE data) GetCipher(self, ciphp); - Check_SafeStr(data); + Check_Type(data, T_STRING); in = RSTRING(data)->ptr; in_len = RSTRING(data)->len; diff --git a/ossl_config.c b/ossl_config.c index 548affc..bce24f4 100644 --- a/ossl_config.c +++ b/ossl_config.c @@ -85,10 +85,10 @@ ossl_config_get_value(VALUE self, VALUE section, VALUE item) GetConfig(self, confp); if (!NIL_P(section)) { - Check_SafeStr(section); + Check_Type(section, T_STRING); sect = RSTRING(section)->ptr; } - Check_SafeStr(item); + Check_Type(item, T_STRING); if (!(str = CONF_get_string(confp->config, sect, RSTRING(item)->ptr))) { OSSL_Raise(eConfigError, ""); @@ -109,7 +109,7 @@ ossl_config_get_section(VALUE self, VALUE section) GetConfig(self, confp); - Check_SafeStr(section); + Check_Type(section, T_STRING); if (!(sk = CONF_get_section(confp->config, RSTRING(section)->ptr))) { OSSL_Raise(eConfigError, ""); diff --git a/ossl_digest.c b/ossl_digest.c index d253545..79ca0bd 100644 --- a/ossl_digest.c +++ b/ossl_digest.c @@ -89,7 +89,7 @@ ossl_digest_update(VALUE self, VALUE data) GetDigest(self, digestp); - Check_SafeStr(data); + Check_Type(data, T_STRING); EVP_DigestUpdate(digestp->md, RSTRING(data)->ptr, RSTRING(data)->len); @@ -209,7 +209,7 @@ ossl_digest_hexdigest(VALUE self) EVP_DigestInit(digestp->md, EVP_##dgst()); \ \ if (rb_scan_args(argc, argv, "01", &data) == 1) { \ - Check_SafeStr(data); \ + Check_Type(data, T_STRING); \ EVP_DigestUpdate(digestp->md, RSTRING(data)->ptr, RSTRING(data)->len); \ } \ return self; \ diff --git a/ossl_hmac.c b/ossl_hmac.c index 43d9a45..8bb5aec 100644 --- a/ossl_hmac.c +++ b/ossl_hmac.c @@ -70,7 +70,7 @@ ossl_hmac_initialize(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "20", &key, &digest); - Check_SafeStr(key); + Check_Type(key, T_STRING); md = ossl_digest_get_EVP_MD(digest); if (!(hmacp->hmac = OPENSSL_malloc(sizeof(HMAC_CTX)))) { @@ -88,7 +88,7 @@ ossl_hmac_update(VALUE self, VALUE data) GetHMAC(self, hmacp); - Check_SafeStr(data); + Check_Type(data, T_STRING); HMAC_Update(hmacp->hmac, RSTRING(data)->ptr, RSTRING(data)->len); diff --git a/ossl_ns_spki.c b/ossl_ns_spki.c index fcea90c..4a99619 100644 --- a/ossl_ns_spki.c +++ b/ossl_ns_spki.c @@ -73,7 +73,6 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self) spki = NETSCAPE_SPKI_new(); break; case T_STRING: - Check_SafeStr(buffer); spki = NETSCAPE_SPKI_b64_decode(RSTRING(buffer)->ptr, -1); break; default: @@ -182,7 +181,7 @@ ossl_spki_set_challenge(VALUE self, VALUE str) ossl_spki *spkip = NULL; GetSPKI(self, spkip); - Check_SafeStr(str); + Check_Type(str, T_STRING); if (!ASN1_STRING_set(spkip->spki->spkac->challenge, RSTRING(str)->ptr, RSTRING(str)->len)) { OSSL_Raise(eSPKIError, ""); diff --git a/ossl_pkcs7.c b/ossl_pkcs7.c index 2d2f260..6345bac 100644 --- a/ossl_pkcs7.c +++ b/ossl_pkcs7.c @@ -131,7 +131,7 @@ static VALUE ossl_pkcs7_s_sign(VALUE klass, VALUE key, VALUE cert, VALUE data) OSSL_Check_Type(key, cPKey); OSSL_Check_Type(cert, X509Certificate); - Check_SafeStr(data); + Check_Type(data, T_STRING); if (rb_funcall(key, rb_intern("private?"), 0, NULL) != Qtrue) { rb_raise(ePKCS7Error, "private key needed!"); @@ -198,7 +198,6 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self) } break; case T_STRING: - Check_SafeStr(arg1); if (!(in = BIO_new_mem_buf(RSTRING(arg1)->ptr, RSTRING(arg1)->len))) { OSSL_Raise(ePKCS7Error, ""); } @@ -374,7 +373,7 @@ ossl_pkcs7_add_data(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "11", &data, &detach); - Check_SafeStr(data); + Check_Type(data, T_STRING); PKCS7_content_new(p7p->pkcs7, NID_pkcs7_data); @@ -421,7 +420,7 @@ ossl_pkcs7_data_verify(int argc, VALUE *argv, VALUE self) store = ossl_x509store_get_X509_STORE(x509store); if (!NIL_P(detached)) { - Check_SafeStr(detached); + Check_Type(detached, T_STRING); if (!(data = BIO_new_mem_buf(RSTRING(detached)->ptr, RSTRING(detached)->len))) { OSSL_Raise(ePKCS7Error, ""); } diff --git a/ossl_pkey_dh.c b/ossl_pkey_dh.c index ea507b5..87db5c8 100644 --- a/ossl_pkey_dh.c +++ b/ossl_pkey_dh.c @@ -122,7 +122,7 @@ ossl_dh_s_new_from_pem(VALUE klass, VALUE buffer) BIO *in = NULL; VALUE obj; - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); if (!(in = BIO_new_mem_buf(RSTRING(buffer)->ptr, RSTRING(buffer)->len))) OSSL_Raise(eDHError, ""); diff --git a/ossl_pkey_dsa.c b/ossl_pkey_dsa.c index 673f752..e62475c 100644 --- a/ossl_pkey_dsa.c +++ b/ossl_pkey_dsa.c @@ -124,10 +124,10 @@ ossl_dsa_s_new_from_pem(int argc, VALUE *argv, VALUE klass) rb_scan_args(argc, argv, "11", &buffer, &pass); - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); if (!NIL_P(pass)) { - Check_SafeStr(pass); + Check_Type(pass, T_STRING); passwd = RSTRING(pass)->ptr; } /* else passwd = NULL; */ @@ -241,7 +241,7 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self) ciph = ossl_cipher_get_EVP_CIPHER(cipher); if (!NIL_P(password)) { - Check_SafeStr(password); + Check_Type(password, T_STRING); pass = RSTRING(password)->ptr; } } @@ -363,7 +363,7 @@ ossl_dsa_sign(VALUE self, VALUE data) VALUE str; GetDSA(self, dsap); - Check_SafeStr(data); + Check_Type(data, T_STRING); if (!DSA_PRIVATE(dsap->dsa)) { rb_raise(eDSAError, "Private DSA key needed!"); @@ -391,8 +391,8 @@ ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig) GetDSA(self, dsap); - Check_SafeStr(digest); - Check_SafeStr(sig); + Check_Type(digest, T_STRING); + Check_Type(sig, T_STRING); ret = DSA_verify(0, RSTRING(digest)->ptr, RSTRING(digest)->len,\ RSTRING(sig)->ptr, RSTRING(sig)->len, dsap->dsa); /*type = 0*/ diff --git a/ossl_pkey_rsa.c b/ossl_pkey_rsa.c index c8612d4..85011e8 100644 --- a/ossl_pkey_rsa.c +++ b/ossl_pkey_rsa.c @@ -125,10 +125,10 @@ ossl_rsa_s_new_from_pem(int argc, VALUE *argv, VALUE klass) rb_scan_args(argc, argv, "11", &buffer, &pass); - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); if (!NIL_P(pass)) { - Check_SafeStr(pass); + Check_Type(pass, T_STRING); passwd = RSTRING(pass)->ptr; } /* else passwd = NULL; */ @@ -232,7 +232,7 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self) ciph = ossl_cipher_get_EVP_CIPHER(cipher); if (!NIL_P(password)) { - Check_SafeStr(password); + Check_Type(password, T_STRING); pass = RSTRING(password)->ptr; } } @@ -269,7 +269,7 @@ ossl_rsa_public_encrypt(VALUE self, VALUE buffer) GetRSA(self, rsap); - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); size = RSA_size(rsap->rsa); @@ -296,7 +296,7 @@ ossl_rsa_public_decrypt(VALUE self, VALUE buffer) GetRSA(self, rsap); - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); size = RSA_size(rsap->rsa); @@ -327,7 +327,7 @@ ossl_rsa_private_encrypt(VALUE self, VALUE buffer) rb_raise(eRSAError, "PRIVATE key needed for this operation!"); } - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); size = RSA_size(rsap->rsa); @@ -358,7 +358,7 @@ ossl_rsa_private_decrypt(VALUE self, VALUE buffer) rb_raise(eRSAError, "Private RSA key needed!"); } - Check_SafeStr(buffer); + Check_Type(buffer, T_STRING); size = RSA_size(rsap->rsa); @@ -507,7 +507,7 @@ ossl_rsa_sign(VALUE self, VALUE digest, VALUE text) GetRSA(self, rsap); OSSL_Check_type(digest, cDigest); - Check_SafeStr(text); + Check_Type(text, T_STRING); if (!(sign = OPENSSL_malloc(RSA_size(rsap->rsa)+16))) { OSSL_Raise(eRSAError, ""); diff --git a/ossl_rand.c b/ossl_rand.c index 037f608..f5be630 100644 --- a/ossl_rand.c +++ b/ossl_rand.c @@ -29,7 +29,7 @@ VALUE eRandomError; static VALUE ossl_rand_seed(VALUE self, VALUE str) { - Check_SafeStr(str); + Check_Type(str, T_STRING); RAND_seed(RSTRING(str)->ptr, RSTRING(str)->len); return str; diff --git a/ossl_x509.c b/ossl_x509.c index 70081c7..e2034e1 100644 --- a/ossl_x509.c +++ b/ossl_x509.c @@ -142,7 +142,6 @@ ossl_x509_initialize(int argc, VALUE *argv, VALUE self) break; case T_STRING: - Check_SafeStr(buffer); if (!(in = BIO_new_mem_buf(RSTRING(buffer)->ptr, RSTRING(buffer)->len))) { OSSL_Raise(eX509CertificateError, ""); } diff --git a/ossl_x509attr.c b/ossl_x509attr.c index 8446afe..c1d982d 100644 --- a/ossl_x509attr.c +++ b/ossl_x509attr.c @@ -100,14 +100,14 @@ ossl_x509attr_s_new_from_array(VALUE klass, VALUE ary) /* key [0] */ item = RARRAY(ary)->ptr[0]; - Check_SafeStr(item); + Check_Type(item, T_STRING); if (!(nid = OBJ_ln2nid(RSTRING(item)->ptr))) if (!(nid = OBJ_sn2nid(RSTRING(item)->ptr))) OSSL_Raise(eX509AttributeError, ""); /* data [1] */ item = RARRAY(ary)->ptr[1]; - Check_SafeStr(item); + Check_Type(item, T_STRING); if (!(attr = X509_ATTRIBUTE_create(nid, MBSTRING_ASC, RSTRING(item)->ptr))) OSSL_Raise(eX509AttributeError, ""); diff --git a/ossl_x509crl.c b/ossl_x509crl.c index d8761c3..c76ca5a 100644 --- a/ossl_x509crl.c +++ b/ossl_x509crl.c @@ -95,7 +95,6 @@ ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self) crl = X509_CRL_new(); break; case T_STRING: - Check_SafeStr(buffer); if (!(in = BIO_new_mem_buf(RSTRING(buffer)->ptr, -1))) { OSSL_Raise(eX509CRLError, ""); } diff --git a/ossl_x509ext.c b/ossl_x509ext.c index 30f9e05..491481d 100644 --- a/ossl_x509ext.c +++ b/ossl_x509ext.c @@ -223,7 +223,7 @@ ossl_x509extfactory_create_ext_from_array(VALUE self, VALUE ary) /* key [0] */ item = RARRAY(ary)->ptr[0]; - Check_SafeStr(item); + Check_Type(item, T_STRING); if (!(nid = OBJ_ln2nid(RSTRING(item)->ptr))) if (!(nid = OBJ_sn2nid(RSTRING(item)->ptr))) { OSSL_Raise(eX509ExtensionError, ""); @@ -231,7 +231,7 @@ ossl_x509extfactory_create_ext_from_array(VALUE self, VALUE ary) /* data [1] */ item = RARRAY(ary)->ptr[1]; - Check_SafeStr(item); + Check_Type(item, T_STRING); /* (optional) critical [2] */ if (RARRAY(ary)->len == 3 && RARRAY(ary)->ptr[2] == Qtrue) { diff --git a/ossl_x509name.c b/ossl_x509name.c index ada54d6..cd68834 100644 --- a/ossl_x509name.c +++ b/ossl_x509name.c @@ -88,8 +88,8 @@ ossl_x509name_hash_i(VALUE key, VALUE value, X509_NAME *name) { int id, type; - Check_SafeStr(key); - Check_SafeStr(value); + Check_Type(key, T_STRING); + Check_Type(value, T_STRING); if (!(id = OBJ_ln2nid(RSTRING(key)->ptr))) if (!(id = OBJ_sn2nid(RSTRING(key)->ptr))) { diff --git a/ossl_x509req.c b/ossl_x509req.c index 3e658bd..285ff98 100644 --- a/ossl_x509req.c +++ b/ossl_x509req.c @@ -116,7 +116,6 @@ ossl_x509req_initialize(int argc, VALUE *argv, VALUE self) req = X509_REQ_new(); break; case T_STRING: - Check_SafeStr(buffer); if (!(in = BIO_new_mem_buf(RSTRING(buffer)->ptr, -1))) { OSSL_Raise(eX509RequestError, ""); } |