[前][次][番号順一覧][スレッド一覧]

ruby-changes:19127

From: naruse <ko1@a...>
Date: Thu, 24 Mar 2011 16:29:33 +0900 (JST)
Subject: [ruby-changes:19127] Ruby:r31166 (trunk): * ext/openssl/ossl.c: surpress warning: shorten-64-to-32.

naruse	2011-03-24 16:29:21 +0900 (Thu, 24 Mar 2011)

  New Revision: 31166

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31166

  Log:
    * ext/openssl/ossl.c: surpress warning: shorten-64-to-32.
    
    * ext/openssl/ossl.h: ditto.
    
    * ext/openssl/ossl_asn1.c: ditto.
    
    * ext/openssl/ossl_bio.c: ditto.
    
    * ext/openssl/ossl_bn.c: ditto.
    
    * ext/openssl/ossl_cipher.c: ditto.
    
    * ext/openssl/ossl_hmac.c: ditto.
    
    * ext/openssl/ossl_ns_spki.c: ditto.
    
    * ext/openssl/ossl_ocsp.c: ditto.
    
    * ext/openssl/ossl_pkcs5.c: ditto.
    
    * ext/openssl/ossl_pkey.c: ditto.
    
    * ext/openssl/ossl_pkey_dh.c: ditto.
    
    * ext/openssl/ossl_pkey_dsa.c: ditto.
    
    * ext/openssl/ossl_pkey_ec.c: ditto.
    
    * ext/openssl/ossl_pkey_rsa.c: ditto.
    
    * ext/openssl/ossl_rand.c: ditto.
    
    * ext/openssl/ossl_ssl.c: ditto.
    
    * ext/openssl/ossl_x509ext.c: ditto.
    
    * ext/openssl/ossl_x509name.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl.c
    trunk/ext/openssl/ossl.h
    trunk/ext/openssl/ossl_asn1.c
    trunk/ext/openssl/ossl_bio.c
    trunk/ext/openssl/ossl_bn.c
    trunk/ext/openssl/ossl_cipher.c
    trunk/ext/openssl/ossl_hmac.c
    trunk/ext/openssl/ossl_ns_spki.c
    trunk/ext/openssl/ossl_ocsp.c
    trunk/ext/openssl/ossl_pkcs5.c
    trunk/ext/openssl/ossl_pkey.c
    trunk/ext/openssl/ossl_pkey_dh.c
    trunk/ext/openssl/ossl_pkey_dsa.c
    trunk/ext/openssl/ossl_pkey_ec.c
    trunk/ext/openssl/ossl_pkey_rsa.c
    trunk/ext/openssl/ossl_rand.c
    trunk/ext/openssl/ossl_ssl.c
    trunk/ext/openssl/ossl_x509ext.c
    trunk/ext/openssl/ossl_x509name.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31165)
+++ ChangeLog	(revision 31166)
@@ -1,3 +1,43 @@
+Thu Mar 24 14:45:57 2011  NARUSE, Yui  <naruse@r...>
+
+	* ext/openssl/ossl.c: surpress warning: shorten-64-to-32.
+
+	* ext/openssl/ossl.h: ditto.
+
+	* ext/openssl/ossl_asn1.c: ditto.
+
+	* ext/openssl/ossl_bio.c: ditto.
+
+	* ext/openssl/ossl_bn.c: ditto.
+
+	* ext/openssl/ossl_cipher.c: ditto.
+
+	* ext/openssl/ossl_hmac.c: ditto.
+
+	* ext/openssl/ossl_ns_spki.c: ditto.
+
+	* ext/openssl/ossl_ocsp.c: ditto.
+
+	* ext/openssl/ossl_pkcs5.c: ditto.
+
+	* ext/openssl/ossl_pkey.c: ditto.
+
+	* ext/openssl/ossl_pkey_dh.c: ditto.
+
+	* ext/openssl/ossl_pkey_dsa.c: ditto.
+
+	* ext/openssl/ossl_pkey_ec.c: ditto.
+
+	* ext/openssl/ossl_pkey_rsa.c: ditto.
+
+	* ext/openssl/ossl_rand.c: ditto.
+
+	* ext/openssl/ossl_ssl.c: ditto.
+
+	* ext/openssl/ossl_x509ext.c: ditto.
+
+	* ext/openssl/ossl_x509name.c: ditto.
+
 Thu Mar 24 11:48:19 2011  NARUSE, Yui  <naruse@r...>
 
 	* ext/openssl/ossl_rand.c (ossl_rand_egd_bytes): use NUM2INT because
Index: ext/openssl/ossl_pkey_dsa.c
===================================================================
--- ext/openssl/ossl_pkey_dsa.c	(revision 31165)
+++ ext/openssl/ossl_pkey_dsa.c	(revision 31166)
@@ -396,7 +396,7 @@
 	ossl_raise(eDSAError, "Private DSA key needed!");
     }
     str = rb_str_new(0, ossl_dsa_buf_size(pkey));
-    if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data),
+    if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
 		  (unsigned char *)RSTRING_PTR(str),
 		  &buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
 	ossl_raise(eDSAError, NULL);
@@ -421,8 +421,8 @@
     StringValue(digest);
     StringValue(sig);
     /* type is ignored (0) */
-    ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LEN(digest),
-		     (unsigned char *)RSTRING_PTR(sig), RSTRING_LEN(sig), pkey->pkey.dsa);
+    ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LENINT(digest),
+		     (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey->pkey.dsa);
     if (ret < 0) {
 	ossl_raise(eDSAError, NULL);
     }
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 31165)
+++ ext/openssl/ossl_ssl.c	(revision 31166)
@@ -232,13 +232,12 @@
 static int
 ossl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
 {
-    VALUE obj;
-    int status, success;
+    VALUE obj, success;
 
     obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
     success = rb_protect((VALUE(*)_((VALUE)))ossl_call_client_cert_cb,
-                         obj, &status);
-    if (status || !success) return 0;
+                         obj, NULL);
+    if (!RTEST(success)) return 0;
     *x509 = DupX509CertPtr(ossl_ssl_get_x509(obj));
     *pkey = DupPKeyPtr(ossl_ssl_get_key(obj));
 
@@ -267,15 +266,14 @@
 static DH*
 ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
 {
-    VALUE args[3];
-    int status, success;
+    VALUE args[3], success;
 
     args[0] = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
     args[1] = INT2FIX(is_export);
     args[2] = INT2FIX(keylength);
     success = rb_protect((VALUE(*)_((VALUE)))ossl_call_tmp_dh_callback,
-                         (VALUE)args, &status);
-    if (status || !success) return NULL;
+                         (VALUE)args, NULL);
+    if (!RTEST(success)) return NULL;
 
     return GetPKeyPtr(ossl_ssl_get_tmp_dh(args[0]))->pkey.dh;
 }
@@ -640,7 +638,7 @@
     if (!NIL_P(val)){
 	StringValue(val);
 	if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val),
-					    RSTRING_LEN(val))){
+					    RSTRING_LENINT(val))){
 	    ossl_raise(eSSLError, "SSL_CTX_set_session_id_context:");
 	}
     }
@@ -1233,7 +1231,7 @@
 	if(!nonblock && SSL_pending(ssl) <= 0)
 	    rb_thread_wait_fd(FPTR_TO_FD(fptr));
 	for (;;){
-	    nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
+	    nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
 	    switch(ssl_get_error(ssl, nread)){
 	    case SSL_ERROR_NONE:
 		goto end;
@@ -1313,7 +1311,7 @@
 
     if (ssl) {
 	for (;;){
-	    nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
+	    nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
 	    switch(ssl_get_error(ssl, nwrite)){
 	    case SSL_ERROR_NONE:
 		goto end;
Index: ext/openssl/ossl_ocsp.c
===================================================================
--- ext/openssl/ossl_ocsp.c	(revision 31165)
+++ ext/openssl/ossl_ocsp.c	(revision 31166)
@@ -136,7 +136,7 @@
     else{
 	StringValue(val);
 	GetOCSPReq(self, req);
-	ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LEN(val));
+	ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
     }
     if(!ret) ossl_raise(eOCSPError, NULL);
 
@@ -440,7 +440,7 @@
     else{
 	StringValue(val);
 	GetOCSPBasicRes(self, bs);
-	ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LEN(val));
+	ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
     }
     if(!ret) ossl_raise(eOCSPError, NULL);
 
Index: ext/openssl/ossl_hmac.c
===================================================================
--- ext/openssl/ossl_hmac.c	(revision 31165)
+++ ext/openssl/ossl_hmac.c	(revision 31166)
@@ -70,7 +70,7 @@
 
     StringValue(key);
     GetHMAC(self, ctx);
-    HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LEN(key),
+    HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
 		 GetDigestPtr(digest), NULL);
 
     return self;
@@ -198,7 +198,7 @@
 
     StringValue(key);
     StringValue(data);
-    buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
+    buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
 	       (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
 
     return rb_str_new((const char *)buf, buf_len);
@@ -220,7 +220,7 @@
     StringValue(key);
     StringValue(data);
 
-    buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
+    buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
 	       (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
     if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) {
 	ossl_raise(eHMACError, "Cannot convert buf to hexbuf");
Index: ext/openssl/ossl_cipher.c
===================================================================
--- ext/openssl/ossl_cipher.c	(revision 31165)
+++ ext/openssl/ossl_cipher.c	(revision 31166)
@@ -217,7 +217,7 @@
 	    else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
 	}
 	EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
-		       (unsigned char *)RSTRING_PTR(pass), RSTRING_LEN(pass), 1, key, NULL);
+		       (unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
 	p_key = key;
 	p_iv = iv;
     }
@@ -300,7 +300,7 @@
     digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
     GetCipher(self, ctx);
     EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
-		   (unsigned char *)RSTRING_PTR(vpass), RSTRING_LEN(vpass), iter, key, iv);
+		   (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
     if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
 	ossl_raise(eCipherError, NULL);
     OPENSSL_cleanse(key, sizeof key);
@@ -330,7 +330,7 @@
 
     StringValue(data);
     in = (unsigned char *)RSTRING_PTR(data);
-    if ((in_len = RSTRING_LEN(data)) == 0)
+    if ((in_len = RSTRING_LENINT(data)) == 0)
         rb_raise(rb_eArgError, "data must not be empty");
     GetCipher(self, ctx);
     out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
Index: ext/openssl/ossl_pkey_rsa.c
===================================================================
--- ext/openssl/ossl_pkey_rsa.c	(revision 31165)
+++ ext/openssl/ossl_pkey_rsa.c	(revision 31166)
@@ -323,7 +323,7 @@
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
     str = rb_str_new(0, ossl_rsa_buf_size(pkey));
-    buf_len = RSA_public_encrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
+    buf_len = RSA_public_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
 				 (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
 				 pad);
     if (buf_len < 0) ossl_raise(eRSAError, NULL);
@@ -352,7 +352,7 @@
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
     str = rb_str_new(0, ossl_rsa_buf_size(pkey));
-    buf_len = RSA_public_decrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
+    buf_len = RSA_public_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
 				 (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
 				 pad);
     if (buf_len < 0) ossl_raise(eRSAError, NULL);
@@ -384,7 +384,7 @@
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
     str = rb_str_new(0, ossl_rsa_buf_size(pkey));
-    buf_len = RSA_private_encrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
+    buf_len = RSA_private_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
 				  (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
 				  pad);
     if (buf_len < 0) ossl_raise(eRSAError, NULL);
@@ -416,7 +416,7 @@
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
     str = rb_str_new(0, ossl_rsa_buf_size(pkey));
-    buf_len = RSA_private_decrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
+    buf_len = RSA_private_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
 				  (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
 				  pad);
     if (buf_len < 0) ossl_raise(eRSAError, NULL);
Index: ext/openssl/ossl_pkey_ec.c
===================================================================
--- ext/openssl/ossl_pkey_ec.c	(revision 31165)
+++ ext/openssl/ossl_pkey_ec.c	(revision 31166)
@@ -671,7 +671,7 @@
 	ossl_raise(eECError, "Private EC key needed!");
 
     str = rb_str_new(0, ECDSA_size(ec) + 16);
-    if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
+    if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
          ossl_raise(eECError, "ECDSA_sign");
 
     rb_str_resize(str, buf_len);
@@ -693,7 +693,7 @@
     StringValue(data);
     StringValue(sig);
 
-    switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(sig), RSTRING_LEN(sig), ec)) {
+    switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(sig), (int)RSTRING_LEN(sig), ec)) {
     case 1:	return Qtrue;
     case 0:	return Qfalse;
     default:	break;
@@ -965,7 +965,7 @@
 {
     EC_builtin_curve *curves = NULL;
     int n;
-    int crv_len = EC_get_builtin_curves(NULL, 0);
+    int crv_len = rb_long2int(EC_get_builtin_curves(NULL, 0));
     VALUE ary, ret;
 
     curves = ALLOCA_N(EC_builtin_curve, crv_len);
Index: ext/openssl/ossl.c
===================================================================
--- ext/openssl/ossl.c	(revision 31165)
+++ ext/openssl/ossl.c	(revision 31166)
@@ -170,7 +170,7 @@
 	rflag = flag ? Qtrue : Qfalse;
 	pass  = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
 	if (status) return -1; /* exception was raised. */
-	len = RSTRING_LEN(pass);
+	len = RSTRING_LENINT(pass);
 	if (len < 4) { /* 4 is OpenSSL hardcoded limit */
 	    rb_warning("password must be longer than 4 bytes");
 	    continue;
@@ -302,7 +302,7 @@
     }
     ERR_clear_error();
 
-    if(len > BUFSIZ) len = strlen(buf);
+    if(len > BUFSIZ) len = rb_long2int(strlen(buf));
     return rb_exc_new(exc, buf, len);
 }
 
Index: ext/openssl/ossl.h
===================================================================
--- ext/openssl/ossl.h	(revision 31165)
+++ ext/openssl/ossl.h	(revision 31166)
@@ -126,8 +126,8 @@
 VALUE ossl_buf2str(char *buf, int len);
 #define ossl_str_adjust(str, p) \
 do{\
-    int len = RSTRING_LEN(str);\
-    int newlen = (p) - (unsigned char*)RSTRING_PTR(str);\
+    int len = RSTRING_LENINT(str);\
+    int newlen = rb_long2int((p) - (unsigned char*)RSTRING_PTR(str));\
     assert(newlen <= len);\
     rb_str_set_len((str), newlen);\
 }while(0)
Index: ext/openssl/ossl_bn.c
===================================================================
--- ext/openssl/ossl_bn.c	(revision 31165)
+++ ext/openssl/ossl_bn.c	(revision 31166)
@@ -133,12 +133,12 @@
 
     switch (base) {
     case 0:
-	if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
+	if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
 	    ossl_raise(eBNError, NULL);
 	}
 	break;
     case 2:
-	if (!BN_bin2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
+	if (!BN_bin2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
 	    ossl_raise(eBNError, NULL);
 	}
 	break;
@@ -198,11 +198,11 @@
 	break;
     case 10:
 	if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
-	str = ossl_buf2str(buf, strlen(buf));
+	str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
 	break;
     case 16:
 	if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
-	str = ossl_buf2str(buf, strlen(buf));
+	str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
 	break;
     default:
 	ossl_raise(rb_eArgError, "invalid radix %d", base);
Index: ext/openssl/ossl_asn1.c
===================================================================
--- ext/openssl/ossl_asn1.c	(revision 31165)
+++ ext/openssl/ossl_asn1.c	(revision 31166)
@@ -223,7 +223,7 @@
     StringValue(obj);
     if(!(bstr = ASN1_BIT_STRING_new()))
 	ossl_raise(eASN1Error, NULL);
-    ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LEN(obj));
+    ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LENINT(obj));
     bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
     bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
 
@@ -238,7 +238,7 @@
     StringValue(obj);
     if(!(str = ASN1_STRING_new()))
 	ossl_raise(eASN1Error, NULL);
-    ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LEN(obj));
+    ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));
 
     return str;
 }
@@ -304,7 +304,7 @@
     str = ossl_to_der(obj);
     if(!(a1str = ASN1_STRING_new()))
 	ossl_raise(eASN1Error, NULL);
-    ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LEN(str));
+    ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str));
 
     return a1str;
 }
@@ -498,7 +498,7 @@
     VALUE value, rflag;
     void *ptr;
     void (*free_func)();
-    long tag, flag;
+    int tag, flag;
 
     tag = ossl_asn1_default_tag(obj);
     value = ossl_asn1_get_value(obj);
@@ -709,11 +709,11 @@
         is_cons = 2;
         tmp_cons = 2;
     }
-    if((length = ASN1_object_size(tmp_cons, RSTRING_LEN(value), tag)) <= 0)
+    if((length = ASN1_object_size(tmp_cons, RSTRING_LENINT(value), tag)) <= 0)
 	ossl_raise(eASN1Error, NULL);
     der = rb_str_new(0, length);
     p = (unsigned char *)RSTRING_PTR(der);
-    ASN1_put_object(&p, is_cons, RSTRING_LEN(value), tag, tag_class);
+    ASN1_put_object(&p, is_cons, RSTRING_LENINT(value), tag, tag_class);
     memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
     p += RSTRING_LEN(value);
     ossl_str_adjust(der, p);
@@ -739,7 +739,7 @@
 	j = ASN1_get_object(&p0, &len, &tag, &tc, length);
 	p = (unsigned char *)p0;
 	if(j & 0x80) ossl_raise(eASN1Error, NULL);
-	hlen = p - start;
+	hlen = rb_long2int(p - start);
 	if(yield){
 	    VALUE arg = rb_ary_new();
 	    rb_ary_push(arg, LONG2NUM(depth));
@@ -784,28 +784,29 @@
 	    VALUE klass = *ossl_asn1_info[tag].klass;
 	    long flag = 0;
 	    if(!rb_obj_is_kind_of(value, rb_cArray)){
+		int l = rb_long2int(hlen + len);
 		switch(tag){
 		case V_ASN1_BOOLEAN:
-		    value = decode_bool(start, hlen+len);
+		    value = decode_bool(start, l);
 		    break;
 		case V_ASN1_INTEGER:
-		    value = decode_int(start, hlen+len);
+		    value = decode_int(start, l);
 		    break;
 		case V_ASN1_BIT_STRING:
-		    value = decode_bstr(start, hlen+len, &flag);
+		    value = decode_bstr(start, l, &flag);
 		    break;
 		case V_ASN1_NULL:
-		    value = decode_null(start, hlen+len);
+		    value = decode_null(start, l);
 		    break;
 		case V_ASN1_ENUMERATED:
-		    value = decode_enum(start, hlen+len);
+		    value = decode_enum(start, l);
 		    break;
 		case V_ASN1_OBJECT:
-		    value = decode_obj(start, hlen+len);
+		    value = decode_obj(start, l);
 		    break;
 		case V_ASN1_UTCTIME:           /* FALLTHROUGH */
 		case V_ASN1_GENERALIZEDTIME:
-		    value = decode_time(start, hlen+len);
+		    value = decode_time(start, l);
 		    break;
 		default:
 		    /* use original value */
@@ -1008,7 +1009,7 @@
     ossl_ASN1_TYPE_free(asn1);
     reallen = p - buf;
     assert(reallen <= len);
-    str = ossl_buf2str((char *)buf, reallen); /* buf will be free in ossl_buf2str */
+    str = ossl_buf2str((char *)buf, rb_long2int(reallen)); /* buf will be free in ossl_buf2str */
 
     return str;
 }
@@ -1017,8 +1018,8 @@
 ossl_asn1cons_to_der(VALUE self)
 {
     int tag, tn, tc, explicit, constructed = 1;
-    int found_prim = 0;
-    long seq_len, length;
+    int found_prim = 0, seq_len;
+    long length;
     unsigned char *p;
     VALUE value, str, inf_length, ary, example;
 
@@ -1060,19 +1061,19 @@
     explicit = ossl_asn1_is_explicit(self);
     value = join_der(ossl_asn1_get_value(self));
 
-    seq_len = ASN1_object_size(constructed, RSTRING_LEN(value), tag);
+    seq_len = ASN1_object_size(constructed, RSTRING_LENINT(value), tag);
     length = ASN1_object_size(constructed, seq_len, tn);
     str = rb_str_new(0, length);
     p = (unsigned char *)RSTRING_PTR(str);
     if(tc == V_ASN1_UNIVERSAL)
-    	ASN1_put_object(&p, constructed, RSTRING_LEN(value), tn, tc);
+	ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
     else{
 	if(explicit){
-    	    ASN1_put_object(&p, constructed, seq_len, tn, tc);
-	    ASN1_put_object(&p, constructed, RSTRING_LEN(value), tag, V_ASN1_UNIVERSAL);
+	    ASN1_put_object(&p, constructed, seq_len, tn, tc);
+	    ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
 	}
         else{
-            ASN1_put_object(&p, constructed, RSTRING_LEN(value), tn, tc);
+            ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
         }
     }
     memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
Index: ext/openssl/ossl_ns_spki.c
===================================================================
--- ext/openssl/ossl_ns_spki.c	(revision 31165)
+++ ext/openssl/ossl_ns_spki.c	(revision 31166)
@@ -106,7 +106,7 @@
     if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
 	ossl_raise(eSPKIError, NULL);
     }
-    str = ossl_buf2str(data, strlen(data));
+    str = ossl_buf2str(data, rb_long2int(strlen(data)));
 
     return str;
 }
@@ -184,7 +184,7 @@
     StringValue(str);
     GetSPKI(self, spki);
     if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str),
-			 RSTRING_LEN(str))) {
+			 RSTRING_LENINT(str))) {
 	ossl_raise(eSPKIError, NULL);
     }
 
Index: ext/openssl/ossl_x509name.c
===================================================================
--- ext/openssl/ossl_x509name.c	(revision 31165)
+++ ext/openssl/ossl_x509name.c	(revision 31166)
@@ -167,7 +167,7 @@
     if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
     GetX509Name(self, name);
     if (!X509_NAME_add_entry_by_txt(name, RSTRING_PTR(oid), NUM2INT(type),
-		(const unsigned char *)RSTRING_PTR(value), RSTRING_LEN(value), -1, 0)) {
+		(const unsigned char *)RSTRING_PTR(value), RSTRING_LENINT(value), -1, 0)) {
 	ossl_raise(eX509NameError, NULL);
     }
 
Index: ext/openssl/ossl_pkey.c
===================================================================
--- ext/openssl/ossl_pkey.c	(revision 31165)
+++ ext/openssl/ossl_pkey.c	(revision 31166)
@@ -194,7 +194,7 @@
     StringValue(sig);
     StringValue(data);
     EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
-    switch (EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LEN(sig), pkey)) {
+    switch (EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey)) {
     case 0:
 	return Qfalse;
     case 1:
Index: ext/openssl/ossl_bio.c
===================================================================
--- ext/openssl/ossl_bio.c	(revision 31165)
+++ ext/openssl/ossl_bio.c	(revision 31166)
@@ -39,7 +39,7 @@
     }
     else {
 	StringValue(obj);
-	bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LEN(obj));
+	bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LENINT(obj));
 	if (!bio) ossl_raise(eOSSLError, NULL);
     }
 
Index: ext/openssl/ossl_pkey_dh.c
===================================================================
--- ext/openssl/ossl_pkey_dh.c	(revision 31165)
+++ ext/openssl/ossl_pkey_dh.c	(revision 31166)
@@ -473,8 +473,8 @@
     DH *dh;
 
     if ((dh = DH_new()) == NULL) ossl_raise(eDHError, NULL);
-    dh->p = BN_bin2bn(p, plen, NULL);
-    dh->g = BN_bin2bn(g, glen, NULL);
+    dh->p = BN_bin2bn(p, rb_long2int(plen), NULL);
+    dh->g = BN_bin2bn(g, rb_long2int(glen), NULL);
     if (dh->p == NULL || dh->g == NULL){
         DH_free(dh);
 	ossl_raise(eDHError, NULL);
Index: ext/openssl/ossl_rand.c
===================================================================
--- ext/openssl/ossl_rand.c	(revision 31165)
+++ ext/openssl/ossl_rand.c	(revision 31166)
@@ -37,7 +37,7 @@
 ossl_rand_seed(VALUE self, VALUE str)
 {
     StringValue(str);
-    RAND_seed(RSTRING_PTR(str), RSTRING_LEN(str));
+    RAND_seed(RSTRING_PTR(str), RSTRING_LENINT(str));
 
     return str;
 }
@@ -51,7 +51,7 @@
 ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
 {
     StringValue(str);
-    RAND_add(RSTRING_PTR(str), RSTRING_LEN(str), NUM2DBL(entropy));
+    RAND_add(RSTRING_PTR(str), RSTRING_LENINT(str), NUM2DBL(entropy));
 
     return self;
 }
Index: ext/openssl/ossl_pkcs5.c
===================================================================
--- ext/openssl/ossl_pkcs5.c	(revision 31165)
+++ ext/openssl/ossl_pkcs5.c	(revision 31166)
@@ -75,8 +75,8 @@
 
     str = rb_str_new(0, len);
 
-    if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LEN(pass),
-			       (const unsigned char *)RSTRING_PTR(salt), RSTRING_LEN(salt), NUM2INT(iter),
+    if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LENINT(pass),
+			       (const unsigned char *)RSTRING_PTR(salt), RSTRING_LENINT(salt), NUM2INT(iter),
 			       len, (unsigned char *)RSTRING_PTR(str)) != 1)
         ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC_SHA1");
 
Index: ext/openssl/ossl_x509ext.c
===================================================================
--- ext/openssl/ossl_x509ext.c	(revision 31165)
+++ ext/openssl/ossl_x509ext.c	(revision 31166)
@@ -340,7 +340,7 @@
 	OPENSSL_free(s);
 	ossl_raise(eX509ExtError, NULL);
     }
-    if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LEN(data))){
+    if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LENINT(data))){
 	OPENSSL_free(s);
 	ASN1_OCTET_STRING_free(asn1s);
 	ossl_raise(eX509ExtError, NULL);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]