aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/socks5.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2020-06-07 16:59:46 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2021-03-02 21:43:42 +0000
commitb22d4c1607b6488b378d3427a708bd71f12f7276 (patch)
tree0ccf88ba2948a72de3c8b31fdcb1cf0ccacdd05c /src/test/fuzz/socks5.cpp
parentb9f41df1ead4b6a83a51fc41966b111c8459c313 (diff)
fuzz: Add fuzzing harness for Socks5(...)
Diffstat (limited to 'src/test/fuzz/socks5.cpp')
-rw-r--r--src/test/fuzz/socks5.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/fuzz/socks5.cpp b/src/test/fuzz/socks5.cpp
new file mode 100644
index 0000000000..1f2f8ee7c3
--- /dev/null
+++ b/src/test/fuzz/socks5.cpp
@@ -0,0 +1,33 @@
+// Copyright (c) 2020 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <netbase.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+void initialize_socks5()
+{
+ static const auto testing_setup = MakeNoLogFileContext<const BasicTestingSetup>();
+}
+
+FUZZ_TARGET_INIT(socks5, initialize_socks5)
+{
+ FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
+ ProxyCredentials proxy_credentials;
+ proxy_credentials.username = fuzzed_data_provider.ConsumeRandomLengthString(512);
+ proxy_credentials.password = fuzzed_data_provider.ConsumeRandomLengthString(512);
+ InterruptSocks5(fuzzed_data_provider.ConsumeBool());
+ FuzzedSock fuzzed_sock = ConsumeSock(fuzzed_data_provider);
+ // This Socks5(...) fuzzing harness would have caught CVE-2017-18350 within
+ // a few seconds of fuzzing.
+ (void)Socks5(fuzzed_data_provider.ConsumeRandomLengthString(512),
+ fuzzed_data_provider.ConsumeIntegral<int>(),
+ fuzzed_data_provider.ConsumeBool() ? &proxy_credentials : nullptr,
+ fuzzed_sock);
+}