Skip to content

Commit 8b67698

Browse files
committed
Merge #17974: [0.18] net: Log to net category for exceptions in ProcessMessages
c89611e 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: ACK c89611e MarcoFalke: ACK c89611e, checked that this is a cherry-pick from 0.19 💐 Tree-SHA512: e48daf64a14d98a78cadd0774a597e5833a1ff19f05527dfc42f3cc38532c1c3bd1acd925c8e0c484e01fbc8c604ee2bcfc0cec0333e9af570b103a6241b657d
2 parents a05d14d + c89611e commit 8b67698

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,35 +3090,10 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
30903090
return false;
30913091
if (!pfrom->vRecvGetData.empty())
30923092
fMoreWork = true;
3093-
}
3094-
catch (const std::ios_base::failure& e)
3095-
{
3096-
if (m_enable_bip61) {
3097-
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
3098-
}
3099-
if (strstr(e.what(), "end of data")) {
3100-
// Allow exceptions from under-length message on vRecv
3101-
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());
3102-
} else if (strstr(e.what(), "size too large")) {
3103-
// Allow exceptions from over-long size
3104-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3105-
} else if (strstr(e.what(), "non-canonical ReadCompactSize()")) {
3106-
// Allow exceptions from non-canonical encoding
3107-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3108-
} else if (strstr(e.what(), "Superfluous witness record")) {
3109-
// Allow exceptions from illegal witness encoding
3110-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3111-
} else if (strstr(e.what(), "Unknown transaction optional data")) {
3112-
// Allow exceptions from unknown witness encoding
3113-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3114-
} else {
3115-
PrintExceptionContinue(&e, "ProcessMessages()");
3116-
}
3117-
}
3118-
catch (const std::exception& e) {
3119-
PrintExceptionContinue(&e, "ProcessMessages()");
3093+
} catch (const std::exception& e) {
3094+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what(), typeid(e).name());
31203095
} catch (...) {
3121-
PrintExceptionContinue(nullptr, "ProcessMessages()");
3096+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(strCommand), nMessageSize);
31223097
}
31233098

31243099
if (!fRet) {

0 commit comments

Comments
 (0)