docs: "Fuzzing the Bitcoin Core P2P layer using Honggfuzz NetDriver" is outdated #28019

issue brunoerg opened this issue on July 1, 2023
  1. brunoerg commented at 9:39 PM on July 1, 2023: contributor

    Due to changes to the functions V1TransportDeserializer::readHeader and V1TransportDeserializer::GetMessage, the "Fuzzing the Bitcoin Core P2P layer using Honggfuzz NetDriver" section in fuzzing.md is outdated. The git apply command doesn't work.

    $ 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;
     }
    
    +#ifdef HFND_FUZZING_ENTRY_FUNCTION_CXX
    +HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
    +#else
     int main(int argc, char* argv[])
    +#endif
     {
     #ifdef WIN32
         util::WinCmdLineArgs winArgs;
    diff --git a/src/net.cpp b/src/net.cpp
    index cf987b699..636a4176a 100644
    --- a/src/net.cpp
    +++ b/src/net.cpp
    @@ -709,7 +709,7 @@ int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
         }
    
         // 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);
             return -1;
         }
    @@ -768,7 +768,7 @@ Optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono::mic
         RandAddEvent(ReadLE32(hash.begin()));
    
         // Check checksum and header command 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)),
    EOF
    
  2. fanquake referenced this in commit 87df084ecb on Jul 3, 2023
  3. fanquake referenced this in commit 1a0958eeba on Jul 3, 2023
  4. fanquake referenced this in commit c1247c3746 on Jul 3, 2023
  5. fanquake closed this on Jul 3, 2023

  6. fanquake referenced this in commit 600c595b8d on Jul 3, 2023
  7. bitcoin locked this on Jul 2, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me