-
Notifications
You must be signed in to change notification settings - Fork 36.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add fuzzing harness for Socks5(...)
1 parent
e4703e1
commit 2a4d581
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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> | ||
|
||
bool Socks5(const std::string& strDest, int port, const ProxyCredentials* auth, Socket& socket); | ||
|
||
void initialize() | ||
{ | ||
InitializeFuzzingContext(); | ||
} | ||
|
||
void test_one_input(const std::vector<uint8_t>& buffer) | ||
{ | ||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; | ||
FuzzedSocket fuzzed_socket = ConsumeSocket(fuzzed_data_provider); | ||
struct ProxyCredentials proxy_credentials; | ||
proxy_credentials.username = fuzzed_data_provider.ConsumeRandomLengthString(512); | ||
proxy_credentials.password = fuzzed_data_provider.ConsumeRandomLengthString(512); | ||
// 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_socket); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters