summaryrefslogtreecommitdiffstats
path: root/security/nss/fuzz/certDN_target.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /security/nss/fuzz/certDN_target.cc
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'security/nss/fuzz/certDN_target.cc')
-rw-r--r--security/nss/fuzz/certDN_target.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/security/nss/fuzz/certDN_target.cc b/security/nss/fuzz/certDN_target.cc
new file mode 100644
index 0000000000..264880ac15
--- /dev/null
+++ b/security/nss/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;
+}