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

Unified Diff: testing/libfuzzer/fuzzers/nss/asn1_bitstring_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 side-by-side diff with in-line comments
Download patch
Index: testing/libfuzzer/fuzzers/nss/asn1_bitstring_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/nss/asn1_bitstring_fuzzer.cc b/testing/libfuzzer/fuzzers/nss/asn1_bitstring_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..49b4f98cde17274f3ab9901c86df5c30a150d8fb
--- /dev/null
+++ b/testing/libfuzzer/fuzzers/nss/asn1_bitstring_fuzzer.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <nss.h>
+#include <nspr.h>
+#include <secasn1.h>
+#include <secder.h>
+#include <secport.h>
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ const SEC_ASN1Template* the_template = SEC_ASN1_GET(SEC_BitStringTemplate);
+ SECItem quick_dest = {siBuffer, nullptr, 0};
+ SECItem legacy_dest = {siBuffer, nullptr, 0};
+
+ // Attempt the QuickDER path.
kcc2 2016/02/10 02:25:22 does this have to be a single target, or it can be
Ryan Sleevi 2016/02/10 02:45:36 Yes, we totally can. Templated logic is totally f
+ PLArenaPool* quick_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+ if (!quick_arena)
+ return 0;
+
+ SECItem quick_src = {siBuffer, const_cast<unsigned char*>(
+ static_cast<const unsigned char*>(data)),
+ static_cast<unsigned int>(size)};
+ SEC_QuickDERDecodeItem(quick_arena, &quick_dest, the_template, &quick_src);
+ PORT_FreeArena(quick_arena, PR_FALSE);
+
+ // Attempt the Legacy path.
+ PLArenaPool* legacy_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+ if (!legacy_arena)
+ return 0;
+
+ SECItem legacy_src = {siBuffer, const_cast<unsigned char*>(
+ static_cast<const unsigned char*>(data)),
+ static_cast<unsigned int>(size)};
+
+ SEC_ASN1DecodeItem(legacy_arena, &legacy_dest, the_template, &legacy_src);
+ PORT_FreeArena(legacy_arena, PR_FALSE);
+
+ return 0;
+}
« no previous file with comments | « testing/libfuzzer/fuzzers/nss/asn1_any_fuzzer.cc ('k') | testing/libfuzzer/fuzzers/nss/asn1_bmpstring_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698