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

ruby-changes:43071

From: rhe <ko1@a...>
Date: Tue, 24 May 2016 21:40:03 +0900 (JST)
Subject: [ruby-changes:43071] rhe:r55145 (trunk): openssl: avoid deprecated M_ASN1_* macros

rhe	2016-05-24 21:39:57 +0900 (Tue, 24 May 2016)

  New Revision: 55145

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55145

  Log:
    openssl: avoid deprecated M_ASN1_* macros
    
    * ext/openssl/ossl_x509ext.c (ossl_x509ext_set_value): Use
      ASN1_OCTET_STRING_set() instead of M_ASN1_OCTET_STRING_set(). Macros
      prefixed by "M_" are discouraged to be used from outside OpenSSL
      library[1].
      (ossl_x509ext_get_value): Likewise, use ASN1_STRING_print() instead
      of M_ASN1_OCTET_STRING_print().
      [1] https://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=CHANGES;h=bf61913d7b01212b4d8b2f3c13d71d645914f67c;hb=b6079a7835f61daa9fb2cbf9addfa86049523933#l878
    
    * ext/openssl/ossl.h: Include openssl/asn1.h instead of
      openssl/asn1_mac.h. It just includes openssl/asn1.h and defines some
      additional "M_" macros.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl.h
    trunk/ext/openssl/ossl_x509ext.c
Index: ext/openssl/ossl_x509ext.c
===================================================================
--- ext/openssl/ossl_x509ext.c	(revision 55144)
+++ ext/openssl/ossl_x509ext.c	(revision 55145)
@@ -358,23 +358,16 @@ ossl_x509ext_set_value(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509ext.c#L358
 {
     X509_EXTENSION *ext;
     ASN1_OCTET_STRING *asn1s;
-    char *s;
 
     data = ossl_to_der_if_possible(data);
     StringValue(data);
-    if(!(s = OPENSSL_malloc(RSTRING_LEN(data))))
-	ossl_raise(eX509ExtError, "malloc error");
-    memcpy(s, RSTRING_PTR(data), RSTRING_LEN(data));
     if(!(asn1s = ASN1_OCTET_STRING_new())){
-	OPENSSL_free(s);
 	ossl_raise(eX509ExtError, NULL);
     }
-    if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LENINT(data))){
-	OPENSSL_free(s);
+    if(!ASN1_STRING_set((ASN1_STRING *)asn1s, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data))){
 	ASN1_OCTET_STRING_free(asn1s);
 	ossl_raise(eX509ExtError, NULL);
     }
-    OPENSSL_free(s);
     GetX509Ext(self, ext);
     X509_EXTENSION_set_data(ext, asn1s);
 
@@ -426,7 +419,7 @@ ossl_x509ext_get_value(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509ext.c#L419
     if (!(out = BIO_new(BIO_s_mem())))
 	ossl_raise(eX509ExtError, NULL);
     if (!X509V3_EXT_print(out, ext, 0, 0))
-	M_ASN1_OCTET_STRING_print(out, ext->value);
+	ASN1_STRING_print(out, (ASN1_STRING *)X509_EXTENSION_get_data(ext));
     ret = ossl_membio2str(out);
 
     return ret;
Index: ext/openssl/ossl.h
===================================================================
--- ext/openssl/ossl.h	(revision 55144)
+++ ext/openssl/ossl.h	(revision 55145)
@@ -54,7 +54,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.h#L54
 #endif
 #include <errno.h>
 #include <openssl/err.h>
-#include <openssl/asn1_mac.h>
+#include <openssl/asn1.h>
 #include <openssl/x509v3.h>
 #include <openssl/ssl.h>
 #include <openssl/pkcs12.h>
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55144)
+++ ChangeLog	(revision 55145)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue May 24 21:32:21 2016  Kazuki Yamaguchi  <k@r...>
+
+	* ext/openssl/ossl_x509ext.c (ossl_x509ext_set_value): Use
+	  ASN1_OCTET_STRING_set() instead of M_ASN1_OCTET_STRING_set(). Macros
+	  prefixed by "M_" are discouraged to be used from outside OpenSSL
+	  library[1].
+	  (ossl_x509ext_get_value): Likewise, use ASN1_STRING_print() instead
+	  of M_ASN1_OCTET_STRING_print().
+	  [1] https://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=CHANGES;h=bf61913d7b01212b4d8b2f3c13d71d645914f67c;hb=b6079a7835f61daa9fb2cbf9addfa86049523933#l878
+
+	* ext/openssl/ossl.h: Include openssl/asn1.h instead of
+	  openssl/asn1_mac.h. It just includes openssl/asn1.h and defines some
+	  additional "M_" macros.
+
 Tue May 24 18:52:11 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/ruby.h (rb_scan_args_verify): verify the format to

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

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