Skip to content

Commit c1247c3

Browse files
committed
docs: fixup honggfuzz patch
Closes #28019.
1 parent 61d59fe commit c1247c3

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

doc/fuzzing.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -219,44 +219,45 @@ $ CC=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang \
219219
./configure --disable-wallet --with-gui=no \
220220
--with-sanitizers=address,undefined
221221
$ git apply << "EOF"
222-
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
223-
index 455a82e39..2faa3f80f 100644
224-
--- a/src/bitcoind.cpp
225-
+++ b/src/bitcoind.cpp
226-
@@ -158,7 +158,11 @@ static bool AppInit(int argc, char* argv[])
227-
return fRet;
228-
}
229-
222+
diff --git a/src/compat/compat.h b/src/compat/compat.h
223+
index 8195bceaec..cce2b31ff0 100644
224+
--- a/src/compat/compat.h
225+
+++ b/src/compat/compat.h
226+
@@ -90,8 +90,12 @@ typedef char* sockopt_arg_type;
227+
// building with a binutils < 2.36 is subject to this ld bug.
228+
#define MAIN_FUNCTION __declspec(dllexport) int main(int argc, char* argv[])
229+
#else
230230
+#ifdef HFND_FUZZING_ENTRY_FUNCTION_CXX
231-
+HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
231+
+#define MAIN_FUNCTION HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
232232
+#else
233-
int main(int argc, char* argv[])
233+
#define MAIN_FUNCTION int main(int argc, char* argv[])
234+
#endif
234235
+#endif
235-
{
236-
#ifdef WIN32
237-
util::WinCmdLineArgs winArgs;
236+
237+
// Note these both should work with the current usage of poll, but best to be safe
238+
// WIN32 poll is broken https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
238239
diff --git a/src/net.cpp b/src/net.cpp
239-
index cf987b699..636a4176a 100644
240+
index 7601a6ea84..702d0f56ce 100644
240241
--- a/src/net.cpp
241242
+++ b/src/net.cpp
242-
@@ -709,7 +709,7 @@ int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
243+
@@ -727,7 +727,7 @@ int V1TransportDeserializer::readHeader(Span<const uint8_t> msg_bytes)
243244
}
244245
245246
// Check start string, network magic
246247
- if (memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
247248
+ if (false && memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { // skip network magic checking
248-
LogPrint(BCLog::NET, "HEADER ERROR - MESSAGESTART (%s, %u bytes), received %s, peer=%d\n", hdr.GetCommand(), hdr.nMessageSize, HexStr(hdr.pchMessageStart), m_node_id);
249+
LogPrint(BCLog::NET, "Header error: Wrong MessageStart %s received, peer=%d\n", HexStr(hdr.pchMessageStart), m_node_id);
249250
return -1;
250251
}
251-
@@ -768,7 +768,7 @@ Optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono::mic
252+
@@ -788,7 +788,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
252253
RandAddEvent(ReadLE32(hash.begin()));
253254
254-
// Check checksum and header command string
255+
// Check checksum and header message type string
255256
- if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
256257
+ if (false && memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { // skip checksum checking
257-
LogPrint(BCLog::NET, "CHECKSUM ERROR (%s, %u bytes), expected %s was %s, peer=%d\n",
258-
SanitizeString(msg->m_command), msg->m_message_size,
259-
HexStr(Span<uint8_t>(hash.begin(), hash.begin() + CMessageHeader::CHECKSUM_SIZE)),
258+
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
259+
SanitizeString(msg.m_type), msg.m_message_size,
260+
HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
260261
EOF
261262
$ make -C src/ bitcoind
262263
$ mkdir -p inputs/

0 commit comments

Comments
 (0)