Skip to content

Commit

Permalink
Bug 1317687 - Speed up nssfuzz cert target some more r=franziskus
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Taubert committed Nov 16, 2016
1 parent 4c3da8d commit 92521eb
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions fuzz/cert_target.cc
Expand Up @@ -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;
}

Expand Down

0 comments on commit 92521eb

Please sign in to comment.