mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge #17974: [0.18] net: Log to net category for exceptions in ProcessMessages
c89611ebd3
net: Log to net category for exceptions in ProcessMessages (Wladimir J. van der Laan) Pull request description: Backport of #17762, currently only backported to 0.19. This seems like something we should opportunistically plug in case wiseguys decide it's a vector to exploit to try and fill people's disks. ACKs for top commit: practicalswift: ACKc89611ebd3
MarcoFalke: ACKc89611ebd3
, checked that this is a cherry-pick from 0.19 💐 Tree-SHA512: e48daf64a14d98a78cadd0774a597e5833a1ff19f05527dfc42f3cc38532c1c3bd1acd925c8e0c484e01fbc8c604ee2bcfc0cec0333e9af570b103a6241b657d
This commit is contained in:
commit
8b67698420
1 changed files with 3 additions and 28 deletions
|
@ -3090,35 +3090,10 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||||
return false;
|
return false;
|
||||||
if (!pfrom->vRecvGetData.empty())
|
if (!pfrom->vRecvGetData.empty())
|
||||||
fMoreWork = true;
|
fMoreWork = true;
|
||||||
}
|
} catch (const std::exception& e) {
|
||||||
catch (const std::ios_base::failure& e)
|
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what(), typeid(e).name());
|
||||||
{
|
|
||||||
if (m_enable_bip61) {
|
|
||||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
|
|
||||||
}
|
|
||||||
if (strstr(e.what(), "end of data")) {
|
|
||||||
// Allow exceptions from under-length message on vRecv
|
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
|
|
||||||
} else if (strstr(e.what(), "size too large")) {
|
|
||||||
// Allow exceptions from over-long size
|
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
|
|
||||||
} else if (strstr(e.what(), "non-canonical ReadCompactSize()")) {
|
|
||||||
// Allow exceptions from non-canonical encoding
|
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
|
|
||||||
} else if (strstr(e.what(), "Superfluous witness record")) {
|
|
||||||
// Allow exceptions from illegal witness encoding
|
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
|
|
||||||
} else if (strstr(e.what(), "Unknown transaction optional data")) {
|
|
||||||
// Allow exceptions from unknown witness encoding
|
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
|
|
||||||
} else {
|
|
||||||
PrintExceptionContinue(&e, "ProcessMessages()");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const std::exception& e) {
|
|
||||||
PrintExceptionContinue(&e, "ProcessMessages()");
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
PrintExceptionContinue(nullptr, "ProcessMessages()");
|
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(strCommand), nMessageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fRet) {
|
if (!fRet) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue