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

ruby-changes:20559

From: emboss <ko1@a...>
Date: Fri, 22 Jul 2011 11:25:16 +0900 (JST)
Subject: [ruby-changes:20559] emboss:r32607 (ruby_1_9_3): * backport r32606 from trunk.

emboss	2011-07-22 11:25:06 +0900 (Fri, 22 Jul 2011)

  New Revision: 32607

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

  Log:
    * backport r32606 from trunk.
    
    * ext/openssl/ossl_digest.c: Check return value of EVP_DigestInit_ex.
    * ext/openssl/ossl_hmac.c: Check return value of HMAC_Init_ex.
      Thanks, Jared Jennings, for the patch.
      [ Ruby 1.9 - Bug #4944 ] [ruby-core:37670]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/openssl/ossl_digest.c
    branches/ruby_1_9_3/ext/openssl/ossl_hmac.c

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 32606)
+++ ruby_1_9_3/ChangeLog	(revision 32607)
@@ -1,3 +1,12 @@
+Fri Jul 22 11:22:20 2011  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* backport r32606 from trunk.
+
+	* ext/openssl/ossl_digest.c: Check return value of EVP_DigestInit_ex.
+	* ext/openssl/ossl_hmac.c: Check return value of HMAC_Init_ex.
+	  Thanks, Jared Jennings, for the patch.
+	  [ Ruby 1.9 - Bug #4944 ] [ruby-core:37670]
+
 Fri Jul 22 09:17:43 2011  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* backport r32604 from trunk.
Index: ruby_1_9_3/ext/openssl/ossl_hmac.c
===================================================================
--- ruby_1_9_3/ext/openssl/ossl_hmac.c	(revision 32606)
+++ ruby_1_9_3/ext/openssl/ossl_hmac.c	(revision 32607)
@@ -70,8 +70,10 @@
 
     StringValue(key);
     GetHMAC(self, ctx);
-    HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
-		 GetDigestPtr(digest), NULL);
+    if (HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
+		 GetDigestPtr(digest), NULL) != 1) {
+	ossl_raise(eHMACError, "HMAC initialization failed.");
+    }
 
     return self;
 }
@@ -180,7 +182,9 @@
     HMAC_CTX *ctx;
 
     GetHMAC(self, ctx);
-    HMAC_Init_ex(ctx, NULL, 0, NULL, NULL);
+    if (HMAC_Init_ex(ctx, NULL, 0, NULL, NULL) != 1) {
+	ossl_raise(eHMACError, "HMAC initialization failed");
+    }
 
     return self;
 }
Index: ruby_1_9_3/ext/openssl/ossl_digest.c
===================================================================
--- ruby_1_9_3/ext/openssl/ossl_digest.c	(revision 32606)
+++ ruby_1_9_3/ext/openssl/ossl_digest.c	(revision 32607)
@@ -68,7 +68,9 @@
 
     ret = ossl_digest_alloc(cDigest);
     GetDigest(ret, ctx);
-    EVP_DigestInit_ex(ctx, md, NULL);
+    if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+	ossl_raise(eDigestError, "Digest initialization failed.");
+    }
 
     return ret;
 }
@@ -122,7 +124,9 @@
     if (!NIL_P(data)) StringValue(data);
 
     GetDigest(self, ctx);
-    EVP_DigestInit_ex(ctx, md, NULL);
+    if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+	ossl_raise(eDigestError, "Digest initialization failed.");
+    }
 
     if (!NIL_P(data)) return ossl_digest_update(self, data);
     return self;
@@ -159,7 +163,9 @@
     EVP_MD_CTX *ctx;
 
     GetDigest(self, ctx);
-    EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL);
+    if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL) != 1) {
+	ossl_raise(eDigestError, "Digest initialization failed.");
+    }
 
     return self;
 }

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

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