diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-12 16:37:53 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-12 17:50:31 +0200 |
commit | efad808aaece74a0308a77e35ad35e845edb97f8 (patch) | |
tree | 5dfd23cb3ebbe97fe4f254c4b7020b1bb5b57400 | |
parent | 3fa1c81b945870dfa4cda469083d4b3e2fa8d459 (diff) |
Avoid reject message feedback loops
-rw-r--r-- | src/main.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index f978254961..7a126ca495 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4106,21 +4106,25 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (strCommand == "reject") { - if (fDebug) - { - string strMsg; unsigned char ccode; string strReason; - vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111); + if (fDebug) { + try { + string strMsg; unsigned char ccode; string strReason; + vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111); - ostringstream ss; - ss << strMsg << " code " << itostr(ccode) << ": " << strReason; + ostringstream ss; + ss << strMsg << " code " << itostr(ccode) << ": " << strReason; - if (strMsg == "block" || strMsg == "tx") - { - uint256 hash; - vRecv >> hash; - ss << ": hash " << hash.ToString(); + if (strMsg == "block" || strMsg == "tx") + { + uint256 hash; + vRecv >> hash; + ss << ": hash " << hash.ToString(); + } + LogPrint("net", "Reject %s\n", SanitizeString(ss.str())); + } catch (std::ios_base::failure& e) { + // Avoid feedback loops by preventing reject messages from triggering a new reject message. + LogPrint("net", "Unparseable reject message received\n"); } - LogPrint("net", "Reject %s\n", SanitizeString(ss.str())); } } |