summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorrnk@chromium.org <rnk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-01 20:02:46 +0000
committerrnk@chromium.org <rnk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-01 20:02:46 +0000
commit0a6ea014d30d61780e611ebd6c9da797021fac7e (patch)
tree464747dac90b0a5a7049e5cf53f8dc614d1eff83 /crypto
parenta8ef38703d9824a23ad49ce96408835edf722509 (diff)
downloadchromium_src-0a6ea014d30d61780e611ebd6c9da797021fac7e.zip
chromium_src-0a6ea014d30d61780e611ebd6c9da797021fac7e.tar.gz
chromium_src-0a6ea014d30d61780e611ebd6c9da797021fac7e.tar.bz2
Fix an SECItem leak in the new ECSignatureCreator class.
R=rch@chromium.org BUG=111317 TEST=ran drmemory on ECSignatureCreator.BasicTest, no longer reports leak Review URL: http://codereview.chromium.org/9302016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ec_signature_creator_nss.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/crypto/ec_signature_creator_nss.cc b/crypto/ec_signature_creator_nss.cc
index 147535b..933f1cc 100644
--- a/crypto/ec_signature_creator_nss.cc
+++ b/crypto/ec_signature_creator_nss.cc
@@ -18,8 +18,7 @@ namespace crypto {
namespace {
-SECStatus SignData(PLArenaPool* arena,
- SECItem* result,
+SECStatus SignData(SECItem* result,
SECItem* input,
SECKEYPrivateKey* key,
HASH_HashType hash_type) {
@@ -72,27 +71,23 @@ bool ECSignatureCreator::Sign(const uint8* data,
secret.len = data_len;
secret.data = const_cast<unsigned char*>(data);
- // |arena| is used to encode the cert.
- crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
- CHECK(arena.get() != NULL);
-
- // Allocate space to contain the signed data.
- SECItem* result = SECITEM_AllocItem(arena.get(), NULL, 0);
- if (!result) {
- DLOG(ERROR) << "Unable to allocate space for signed data.";
- return false;
- }
+ // SECItem to receive the output buffer.
+ SECItem result;
+ result.type = siBuffer;
+ result.len = 0;
+ result.data = NULL;
// Sign the secret data and save it to |result|.
SECStatus rv =
- SignData(arena.get(), result, &secret, key_->key(), HASH_AlgSHA1);
+ SignData(&result, &secret, key_->key(), HASH_AlgSHA1);
if (rv != SECSuccess) {
DLOG(ERROR) << "DerSignData: " << PORT_GetError();
return false;
}
// Copy the signed data into the output vector.
- signature->assign(result->data, result->data + result->len);
+ signature->assign(result.data, result.data + result.len);
+ SECITEM_FreeItem(&result, PR_FALSE /* only free |result.data| */);
return true;
}