aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-16 18:52:22 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-09-16 18:54:46 +0200
commit13168ea46cf67e3f3c8dd258ab91c01ee0e1ebc4 (patch)
tree8cc8a2e69efebc943c13a795bf4954e34dd305e2 /src
parentcf04923618f552e660e7156200f6c84f0ed5b60d (diff)
parentefad808aaece74a0308a77e35ad35e845edb97f8 (diff)
Merge pull request #4903
efad808 Avoid reject message feedback loops (Pieter Wuille)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3c19407b95..766553d948 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4111,21 +4111,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()));
}
}