summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorFranziskus Kiefer <franziskuskiefer@gmail.com>2017-01-25 15:03:54 +0100
committerFranziskus Kiefer <franziskuskiefer@gmail.com>2017-01-25 15:03:54 +0100
commit771c895c8b0ad2b76633cd313134b6bc227aaf1e (patch)
treec74f82a9aa64dea7ef68e74885e8f0dcfeae6925 /fuzz
parent37425a452d3f5800348e875ac6bf4c752488b233 (diff)
downloadnss-hg-771c895c8b0ad2b76633cd313134b6bc227aaf1e.tar.gz
Bug 1334098 - fuzz alg1485, r=ttaubert
Differential Revision: https://nss-review.dev.mozaws.net/D174
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/certDN_target.cc45
-rw-r--r--fuzz/fuzz.gyp12
-rw-r--r--fuzz/pkcs8_target.cc1
3 files changed, 57 insertions, 1 deletions
diff --git a/fuzz/certDN_target.cc b/fuzz/certDN_target.cc
new file mode 100644
index 000000000..447016494
--- /dev/null
+++ b/fuzz/certDN_target.cc
@@ -0,0 +1,45 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 <string>
+
+#include "shared.h"
+
+#define TEST_FUNCTION(f) \
+ out = f(certName); \
+ free(out);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ std::string name(data, data + size);
+
+ assert(SECOID_Init() == SECSuccess);
+
+ CERTName* certName = CERT_AsciiToName(name.c_str());
+ if (certName) {
+ char *out;
+ TEST_FUNCTION(CERT_NameToAscii)
+ TEST_FUNCTION(CERT_GetCertEmailAddress)
+
+ // These functions call CERT_GetNameElement with different OIDs.
+ // Unfotunately CERT_GetNameElement is not accesible from here.
+ TEST_FUNCTION(CERT_GetCertUid)
+ TEST_FUNCTION(CERT_GetCommonName)
+ TEST_FUNCTION(CERT_GetCountryName)
+ TEST_FUNCTION(CERT_GetDomainComponentName)
+ TEST_FUNCTION(CERT_GetLocalityName)
+ TEST_FUNCTION(CERT_GetOrgName)
+ TEST_FUNCTION(CERT_GetOrgUnitName)
+ TEST_FUNCTION(CERT_GetStateName)
+
+ out = CERT_NameToAsciiInvertible(certName, CERT_N2A_READABLE);
+ free(out);
+ out = CERT_NameToAsciiInvertible(certName, CERT_N2A_STRICT);
+ free(out);
+ out = CERT_NameToAsciiInvertible(certName, CERT_N2A_INVERTIBLE);
+ free(out);
+ }
+ CERT_DestroyName(certName);
+
+ return 0;
+}
diff --git a/fuzz/fuzz.gyp b/fuzz/fuzz.gyp
index decf0c7c1..9b42d4889 100644
--- a/fuzz/fuzz.gyp
+++ b/fuzz/fuzz.gyp
@@ -145,9 +145,21 @@
],
},
{
+ 'target_name': 'nssfuzz-certDN',
+ 'type': 'executable',
+ 'sources': [
+ 'certDN_target.cc',
+ ],
+ 'dependencies': [
+ '<(DEPTH)/exports.gyp:nss_exports',
+ 'fuzz_base',
+ ],
+ },
+ {
'target_name': 'nssfuzz',
'type': 'none',
'dependencies': [
+ 'nssfuzz-certDN',
'nssfuzz-hash',
'nssfuzz-mpi',
'nssfuzz-pkcs8',
diff --git a/fuzz/pkcs8_target.cc b/fuzz/pkcs8_target.cc
index 4c6849090..b6b90c99c 100644
--- a/fuzz/pkcs8_target.cc
+++ b/fuzz/pkcs8_target.cc
@@ -9,7 +9,6 @@
#include "pk11pub.h"
#include "asn1_mutators.h"
-#include "assert.h"
#include "shared.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {