forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: Add fuzzing harness for Socks5(...)
- Loading branch information
1 parent
b9f41df
commit b22d4c1
Showing
5 changed files
with
166 additions
and
8 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
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,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); | ||
} |
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