summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason.piao <jason.piao@mongodb.com>2019-06-24 14:15:29 -0400
committerjason.piao <jason.piao@mongodb.com>2019-07-11 17:55:14 -0400
commitd75af1030805a98ac7482fa7c6ceb6667cbe7f21 (patch)
treeb4fd6978b22345f59c5aa668e272bc0124ce1001
parent09e14555877947afc5dac351a4c8632febd8ea03 (diff)
downloadmongo-d75af1030805a98ac7482fa7c6ceb6667cbe7f21.tar.gz
SERVER-41704 adding asn1 libfuzzer parser
-rw-r--r--src/mongo/util/net/SConscript11
-rw-r--r--src/mongo/util/net/asn1_parser_fuzzer.cpp37
2 files changed, 48 insertions, 0 deletions
diff --git a/src/mongo/util/net/SConscript b/src/mongo/util/net/SConscript
index daddb3c4ed0..c4ab9713f0b 100644
--- a/src/mongo/util/net/SConscript
+++ b/src/mongo/util/net/SConscript
@@ -205,6 +205,17 @@ env.CppUnitTest(
],
)
+env.CppLibfuzzerTest(
+ target='asn1_parser_fuzzer',
+ source=[
+ 'asn1_parser_fuzzer.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
+ ],
+)
+
if get_option('ssl') == 'on':
env.CppUnitTest(
target='util_net_ssl_test',
diff --git a/src/mongo/util/net/asn1_parser_fuzzer.cpp b/src/mongo/util/net/asn1_parser_fuzzer.cpp
new file mode 100644
index 00000000000..f8e925028b8
--- /dev/null
+++ b/src/mongo/util/net/asn1_parser_fuzzer.cpp
@@ -0,0 +1,37 @@
+/**
+ * Copyright (C) 2019-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/base/data_range.h"
+#include "mongo/util/net/ssl_manager.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const char* Data, size_t Size) {
+ mongo::ConstDataRange dr = mongo::ConstDataRange(Data, Size);
+ auto ret = mongo::parsePeerRoles(dr);
+ return 0;
+}