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

Side by Side Diff: testing/libfuzzer/fuzzers/nss/asn1_fuzzer_template.h

Issue 1677803002: Add a bunch of NSS ASN.1 fuzzers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix leak Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASN1_FUZZER_TEMPLATE_H_
6 #define ASN1_FUZZER_TEMPLATE_H_
7
8 #include <nspr.h>
9 #include <nss.h>
10 #include <secasn1.h>
11 #include <secder.h>
12 #include <secitem.h>
13 #include <secport.h>
14 #include <stddef.h>
15 #include <stdint.h>
16
17 template <typename DestinationType,
18 SECStatus (*DecodeFunction)(PLArenaPool*,
19 void*,
20 const SEC_ASN1Template*,
21 const SECItem*)>
22 void NSSFuzzOneInput(const SEC_ASN1Template* the_template,
23 const uint8_t* data,
24 size_t size) {
25 DestinationType* destination = new DestinationType();
26 memset(destination, 0, sizeof(DestinationType));
27
28 PLArenaPool* arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
29 if (!arena) {
30 delete destination;
31 return;
32 }
33
34 SECItem source;
35 source.type = siBuffer;
36 source.data = static_cast<unsigned char*>(const_cast<uint8_t*>(data));
37 source.len = static_cast<unsigned int>(size);
38
39 DecodeFunction(arena, destination, the_template, &source);
40
41 PORT_FreeArena(arena, PR_FALSE);
42 delete destination;
43 }
44
45 #endif // ASN1_FUZZER_TEMPLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698