diff options
author | Tim Taubert <ttaubert@mozilla.com> | 2016-11-16 11:02:41 +0100 |
---|---|---|
committer | Tim Taubert <ttaubert@mozilla.com> | 2016-11-16 11:02:41 +0100 |
commit | e0f5d95f652a38808f1ffe754693b8459c983be1 (patch) | |
tree | 01be54a5cee24c553006af67c08e0cfe42d8533f /fuzz | |
parent | 0e2cad67a1bc685daa1dd2a95a7e1a8e9b2a050f (diff) | |
download | nss-hg-e0f5d95f652a38808f1ffe754693b8459c983be1.tar.gz |
Bug 1317687 - Speed up nssfuzz cert target some more r=franziskus
Differential Revision: https://nss-review.dev.mozaws.net/D71
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/cert_target.cc | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fuzz/cert_target.cc b/fuzz/cert_target.cc index d7210ef9a..bb83893c5 100644 --- a/fuzz/cert_target.cc +++ b/fuzz/cert_target.cc @@ -4,28 +4,22 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <assert.h> #include <stdint.h> -#include <memory> #include "cert.h" #include "registry.h" -#include "shared.h" extern "C" int cert_fuzzing_target(const uint8_t *Data, size_t Size) { - SECItem data = {siBuffer, (unsigned char *)Data, (unsigned int)Size}; - - static std::unique_ptr<NSSDatabase> db(new NSSDatabase()); - assert(db != nullptr); + PORTCheapArenaPool pool; + PORT_InitCheapArena(&pool, DER_DEFAULT_CHUNKSIZE); - CERTCertificate *cert = CERT_DecodeDERCertificate( - &data, false, const_cast<char *>("certificate")); - - if (cert) { - CERT_DestroyCertificate(cert); - } + CERTCertificate cert; + SECItem data = {siBuffer, (unsigned char *)Data, (unsigned int)Size}; + SEC_QuickDERDecodeItem(&pool.arena, &cert, SEC_SignedCertificateTemplate, + &data); + PORT_DestroyCheapArena(&pool); return 0; } |