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

Side by Side Diff: testing/libfuzzer/fuzzers/nss/asn1_bmpstring_fuzzer.cc

Issue 1677803002: Add a bunch of NSS ASN.1 fuzzers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop zeroing our stuff Created 4 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 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 #include <stddef.h>
6 #include <stdint.h>
7
8 #include <nss.h>
9 #include <nspr.h>
10 #include <secasn1.h>
11 #include <secder.h>
12 #include <secport.h>
13
14 // Entry point for LibFuzzer.
15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
16 const SEC_ASN1Template* the_template = SEC_ASN1_GET(SEC_BMPStringTemplate);
17 SECItem quick_dest = {siBuffer, nullptr, 0};
18 SECItem legacy_dest = {siBuffer, nullptr, 0};
19
20 // Attempt the QuickDER path.
21 PLArenaPool* quick_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
22 if (!quick_arena)
23 return 0;
24
25 SECItem quick_src = {siBuffer, const_cast<unsigned char*>(
26 static_cast<const unsigned char*>(data)),
27 static_cast<unsigned int>(size)};
28 SEC_QuickDERDecodeItem(quick_arena, &quick_dest, the_template, &quick_src);
29 PORT_FreeArena(quick_arena, PR_FALSE);
30
31 // Attempt the Legacy path.
32 PLArenaPool* legacy_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
33 if (!legacy_arena)
34 return 0;
35
36 SECItem legacy_src = {siBuffer, const_cast<unsigned char*>(
37 static_cast<const unsigned char*>(data)),
38 static_cast<unsigned int>(size)};
39
40 SEC_ASN1DecodeItem(legacy_arena, &legacy_dest, the_template, &legacy_src);
41 PORT_FreeArena(legacy_arena, PR_FALSE);
42
43 return 0;
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698