Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3388)

Unified Diff: crypto/signature_verifier_win.cc

Issue 9358080: Properly parse UTF8Strings in certificates on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: crypto/signature_verifier_win.cc
diff --git a/crypto/signature_verifier_win.cc b/crypto/signature_verifier_win.cc
index d294c4d41a8fb5c3b0d045cd3734222218a84d4b..37f30fd045543b58555741e686c5bae5d722f1cd 100644
--- a/crypto/signature_verifier_win.cc
+++ b/crypto/signature_verifier_win.cc
@@ -5,23 +5,10 @@
#include "crypto/signature_verifier.h"
#include "base/logging.h"
+#include "crypto/capi_util.h"
#pragma comment(lib, "crypt32.lib")
-namespace {
-
-// Wrappers of malloc and free for CRYPT_DECODE_PARA, which requires the
-// WINAPI calling convention.
-void* WINAPI MyCryptAlloc(size_t size) {
- return malloc(size);
-}
-
-void WINAPI MyCryptFree(void* p) {
- free(p);
-}
-
-} // namespace
-
namespace crypto {
SignatureVerifier::SignatureVerifier() : hash_object_(0), public_key_(0) {
@@ -47,8 +34,8 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
CRYPT_DECODE_PARA decode_para;
decode_para.cbSize = sizeof(decode_para);
- decode_para.pfnAlloc = MyCryptAlloc;
- decode_para.pfnFree = MyCryptFree;
+ decode_para.pfnAlloc = crypto::CryptAllocFunction;
+ decode_para.pfnFree = crypto::CryptFreeFunction;
CERT_PUBLIC_KEY_INFO* cert_public_key_info = NULL;
DWORD struct_len = 0;
BOOL ok;
@@ -66,7 +53,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
ok = CryptImportPublicKeyInfo(provider_,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
cert_public_key_info, public_key_.receive());
- free(cert_public_key_info);
+ crypto::CryptFreeFunction(cert_public_key_info);
if (!ok)
return false;
@@ -89,7 +76,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
hash_alg_id = CALG_SHA1;
else if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_MD5RSA))
hash_alg_id = CALG_MD5;
- free(signature_algorithm_id);
+ crypto::CryptFreeFunction(signature_algorithm_id);
DCHECK_NE(static_cast<ALG_ID>(CALG_MD4), hash_alg_id);
if (hash_alg_id == CALG_MD4)
return false; // Unsupported hash algorithm.

Powered by Google App Engine
This is Rietveld 408576698