aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-07-03 11:44:44 +0100
committerfanquake <fanquake@gmail.com>2023-07-03 11:44:55 +0100
commit600c595b8d2f4bf049b9182d4a0aa88e4b34458d (patch)
treeff39ec9e427ded101a55ef7c6d96a2ab7df1a23f
parent61d59fed74108f31eb4e9a2faa3f36422a37000e (diff)
parentc1247c3746d4b9ea88a0f9cfb7e71904267b3cd3 (diff)
Merge bitcoin/bitcoin#28021: docs: fixup honggfuzz fuzz patch
c1247c3746d4b9ea88a0f9cfb7e71904267b3cd3 docs: fixup honggfuzz patch (fanquake) Pull request description: Closes #28019. ACKs for top commit: brunoerg: ACK c1247c3746d4b9ea88a0f9cfb7e71904267b3cd3 Tree-SHA512: 3f2d146d3d0c24fd25458f6a41e2d20bf6024fc0ea9942ee6254a1b6d0e3c017c55fe79dfbf90652cad64a4d6f026f463b0011dfab065b3d9754ca7047018084
-rw-r--r--doc/fuzzing.md43
1 files changed, 22 insertions, 21 deletions
diff --git a/doc/fuzzing.md b/doc/fuzzing.md
index 84ebb0986d..a4b0198dd9 100644
--- a/doc/fuzzing.md
+++ b/doc/fuzzing.md
@@ -219,44 +219,45 @@ $ CC=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang \
./configure --disable-wallet --with-gui=no \
--with-sanitizers=address,undefined
$ git apply << "EOF"
-diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
-index 455a82e39..2faa3f80f 100644
---- a/src/bitcoind.cpp
-+++ b/src/bitcoind.cpp
-@@ -158,7 +158,11 @@ static bool AppInit(int argc, char* argv[])
- return fRet;
- }
-
+diff --git a/src/compat/compat.h b/src/compat/compat.h
+index 8195bceaec..cce2b31ff0 100644
+--- a/src/compat/compat.h
++++ b/src/compat/compat.h
+@@ -90,8 +90,12 @@ typedef char* sockopt_arg_type;
+ // building with a binutils < 2.36 is subject to this ld bug.
+ #define MAIN_FUNCTION __declspec(dllexport) int main(int argc, char* argv[])
+ #else
+#ifdef HFND_FUZZING_ENTRY_FUNCTION_CXX
-+HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
++#define MAIN_FUNCTION HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
+#else
- int main(int argc, char* argv[])
+ #define MAIN_FUNCTION int main(int argc, char* argv[])
+ #endif
+#endif
- {
- #ifdef WIN32
- util::WinCmdLineArgs winArgs;
+
+ // Note these both should work with the current usage of poll, but best to be safe
+ // WIN32 poll is broken https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
diff --git a/src/net.cpp b/src/net.cpp
-index cf987b699..636a4176a 100644
+index 7601a6ea84..702d0f56ce 100644
--- a/src/net.cpp
+++ b/src/net.cpp
-@@ -709,7 +709,7 @@ int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
+@@ -727,7 +727,7 @@ int V1TransportDeserializer::readHeader(Span<const uint8_t> msg_bytes)
}
// Check start string, network magic
- if (memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
+ if (false && memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { // skip network magic checking
- LogPrint(BCLog::NET, "HEADER ERROR - MESSAGESTART (%s, %u bytes), received %s, peer=%d\n", hdr.GetCommand(), hdr.nMessageSize, HexStr(hdr.pchMessageStart), m_node_id);
+ LogPrint(BCLog::NET, "Header error: Wrong MessageStart %s received, peer=%d\n", HexStr(hdr.pchMessageStart), m_node_id);
return -1;
}
-@@ -768,7 +768,7 @@ Optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono::mic
+@@ -788,7 +788,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
RandAddEvent(ReadLE32(hash.begin()));
- // Check checksum and header command string
+ // Check checksum and header message type string
- if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
+ if (false && memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { // skip checksum checking
- LogPrint(BCLog::NET, "CHECKSUM ERROR (%s, %u bytes), expected %s was %s, peer=%d\n",
- SanitizeString(msg->m_command), msg->m_message_size,
- HexStr(Span<uint8_t>(hash.begin(), hash.begin() + CMessageHeader::CHECKSUM_SIZE)),
+ LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
+ SanitizeString(msg.m_type), msg.m_message_size,
+ HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
EOF
$ make -C src/ bitcoind
$ mkdir -p inputs/