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

ruby-changes:43862

From: usa <ko1@a...>
Date: Tue, 16 Aug 2016 20:33:40 +0900 (JST)
Subject: [ruby-changes:43862] usa:r55935 (ruby_2_2): merge revision(s) 55175: [Backport #12428]

usa	2016-08-16 20:33:35 +0900 (Tue, 16 Aug 2016)

  New Revision: 55935

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

  Log:
    merge revision(s) 55175: [Backport #12428]
    
    * ext/openssl/ossl_pkey_dh.c (ossl_dh_compute_key): Check that the DH
      has 'p' (the prime) before calling DH_size(). We can create a DH with
      no parameter but DH_size() does not check and dereferences NULL.
      [ruby-core:75720] [Bug #12428]
    
    * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_sign): Ditto. DSA_size() does
      not check dsa->q.
    
    * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_public_encrypt,
      ossl_rsa_public_decrypt, ossl_rsa_private_encrypt,
      ossl_rsa_private_decrypt): Ditto. RSA_size() does not check rsa->n.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ext/openssl/ossl_pkey_dh.c
    branches/ruby_2_2/ext/openssl/ossl_pkey_dsa.c
    branches/ruby_2_2/ext/openssl/ossl_pkey_rsa.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 55934)
+++ ruby_2_2/ChangeLog	(revision 55935)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Aug 16 20:30:53 2016  Kazuki Yamaguchi  <k@r...>
+
+	* ext/openssl/ossl_pkey_dh.c (ossl_dh_compute_key): Check that the DH
+	  has 'p' (the prime) before calling DH_size(). We can create a DH with
+	  no parameter but DH_size() does not check and dereferences NULL.
+	  [ruby-core:75720] [Bug #12428]
+
+	* ext/openssl/ossl_pkey_dsa.c (ossl_dsa_sign): Ditto. DSA_size() does
+	  not check dsa->q.
+
+	* ext/openssl/ossl_pkey_rsa.c (ossl_rsa_public_encrypt,
+	  ossl_rsa_public_decrypt, ossl_rsa_private_encrypt,
+	  ossl_rsa_private_decrypt): Ditto. RSA_size() does not check rsa->n.
+
 Tue Aug 16 20:28:24 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* transcode.c (enc_arg, str_transcode_enc_args, econv_args):
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 55934)
+++ ruby_2_2/version.h	(revision 55935)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-08-16"
-#define RUBY_PATCHLEVEL 361
+#define RUBY_PATCHLEVEL 362
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_2/ext/openssl/ossl_pkey_rsa.c
===================================================================
--- ruby_2_2/ext/openssl/ossl_pkey_rsa.c	(revision 55934)
+++ ruby_2_2/ext/openssl/ossl_pkey_rsa.c	(revision 55935)
@@ -390,6 +390,8 @@ ossl_rsa_public_encrypt(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_rsa.c#L390
     VALUE str, buffer, padding;
 
     GetPKeyRSA(self, pkey);
+    if (!pkey->pkey.rsa->n)
+	ossl_raise(eRSAError, "incomplete RSA");
     rb_scan_args(argc, argv, "11", &buffer, &padding);
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
@@ -419,6 +421,8 @@ ossl_rsa_public_decrypt(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_rsa.c#L421
     VALUE str, buffer, padding;
 
     GetPKeyRSA(self, pkey);
+    if (!pkey->pkey.rsa->n)
+	ossl_raise(eRSAError, "incomplete RSA");
     rb_scan_args(argc, argv, "11", &buffer, &padding);
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
@@ -448,9 +452,10 @@ ossl_rsa_private_encrypt(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_rsa.c#L452
     VALUE str, buffer, padding;
 
     GetPKeyRSA(self, pkey);
-    if (!RSA_PRIVATE(self, pkey->pkey.rsa)) {
-	ossl_raise(eRSAError, "private key needed.");
-    }
+    if (!pkey->pkey.rsa->n)
+	ossl_raise(eRSAError, "incomplete RSA");
+    if (!RSA_PRIVATE(self, pkey->pkey.rsa))
+	ossl_raise(eRSAError, "private key needed");
     rb_scan_args(argc, argv, "11", &buffer, &padding);
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
@@ -480,9 +485,10 @@ ossl_rsa_private_decrypt(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_rsa.c#L485
     VALUE str, buffer, padding;
 
     GetPKeyRSA(self, pkey);
-    if (!RSA_PRIVATE(self, pkey->pkey.rsa)) {
-	ossl_raise(eRSAError, "private key needed.");
-    }
+    if (!pkey->pkey.rsa->n)
+	ossl_raise(eRSAError, "incomplete RSA");
+    if (!RSA_PRIVATE(self, pkey->pkey.rsa))
+	ossl_raise(eRSAError, "private key needed");
     rb_scan_args(argc, argv, "11", &buffer, &padding);
     pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
     StringValue(buffer);
Index: ruby_2_2/ext/openssl/ossl_pkey_dh.c
===================================================================
--- ruby_2_2/ext/openssl/ossl_pkey_dh.c	(revision 55934)
+++ ruby_2_2/ext/openssl/ossl_pkey_dh.c	(revision 55935)
@@ -505,6 +505,8 @@ ossl_dh_compute_key(VALUE self, VALUE pu https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_dh.c#L505
 
     GetPKeyDH(self, pkey);
     dh = pkey->pkey.dh;
+    if (!dh->p)
+	ossl_raise(eDHError, "incomplete DH");
     pub_key = GetBNPtr(pub);
     len = DH_size(dh);
     str = rb_str_new(0, len);
Index: ruby_2_2/ext/openssl/ossl_pkey_dsa.c
===================================================================
--- ruby_2_2/ext/openssl/ossl_pkey_dsa.c	(revision 55934)
+++ ruby_2_2/ext/openssl/ossl_pkey_dsa.c	(revision 55935)
@@ -497,10 +497,11 @@ ossl_dsa_sign(VALUE self, VALUE data) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_pkey_dsa.c#L497
     VALUE str;
 
     GetPKeyDSA(self, pkey);
-    StringValue(data);
-    if (!DSA_PRIVATE(self, pkey->pkey.dsa)) {
+    if (!pkey->pkey.dsa->q)
+	ossl_raise(eDSAError, "incomplete DSA");
+    if (!DSA_PRIVATE(self, pkey->pkey.dsa))
 	ossl_raise(eDSAError, "Private DSA key needed!");
-    }
+    StringValue(data);
     str = rb_str_new(0, ossl_dsa_buf_size(pkey));
     if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
 		  (unsigned char *)RSTRING_PTR(str),

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r55175


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

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