ruby-changes:20558
From: emboss <ko1@a...>
Date: Fri, 22 Jul 2011 11:21:38 +0900 (JST)
Subject: [ruby-changes:20558] emboss:r32606 (trunk): * ext/openssl/ossl_digest.c: Check return value of EVP_DigestInit_ex.
emboss 2011-07-22 11:21:26 +0900 (Fri, 22 Jul 2011) New Revision: 32606 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32606 Log: * 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: trunk/ChangeLog trunk/ext/openssl/ossl_digest.c trunk/ext/openssl/ossl_hmac.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32605) +++ ChangeLog (revision 32606) @@ -1,3 +1,10 @@ +Fri Jul 22 11:20:20 2011 Martin Bosslet <Martin.Bosslet@g...> + + * 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:09:43 2011 Martin Bosslet <Martin.Bosslet@g...> * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference. Index: ext/openssl/ossl_hmac.c =================================================================== --- ext/openssl/ossl_hmac.c (revision 32605) +++ ext/openssl/ossl_hmac.c (revision 32606) @@ -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: ext/openssl/ossl_digest.c =================================================================== --- ext/openssl/ossl_digest.c (revision 32605) +++ ext/openssl/ossl_digest.c (revision 32606) @@ -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/