Skip to content

Commit 4d88c3d

Browse files
committed
net: Log to net category for exceptions in ProcessMessages
Remove the forest of special exceptions, and simply log a short message to the NET logging category when an exception happens during packet processing. It is not good to panick end users with errors that any peer can generate (let alone writing to stderr).
1 parent 5e4912f commit 4d88c3d

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,32 +3333,10 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
33333333
return false;
33343334
if (!pfrom->vRecvGetData.empty())
33353335
fMoreWork = true;
3336-
}
3337-
catch (const std::ios_base::failure& e)
3338-
{
3339-
if (strstr(e.what(), "end of data")) {
3340-
// Allow exceptions from under-length message on vRecv
3341-
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());
3342-
} else if (strstr(e.what(), "size too large")) {
3343-
// Allow exceptions from over-long size
3344-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3345-
} else if (strstr(e.what(), "non-canonical ReadCompactSize()")) {
3346-
// Allow exceptions from non-canonical encoding
3347-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3348-
} else if (strstr(e.what(), "Superfluous witness record")) {
3349-
// Allow exceptions from illegal witness encoding
3350-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3351-
} else if (strstr(e.what(), "Unknown transaction optional data")) {
3352-
// Allow exceptions from unknown witness encoding
3353-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3354-
} else {
3355-
PrintExceptionContinue(&e, "ProcessMessages()");
3356-
}
3357-
}
3358-
catch (const std::exception& e) {
3359-
PrintExceptionContinue(&e, "ProcessMessages()");
3336+
} catch (const std::exception& e) {
3337+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what(), typeid(e).name());
33603338
} catch (...) {
3361-
PrintExceptionContinue(nullptr, "ProcessMessages()");
3339+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(strCommand), nMessageSize);
33623340
}
33633341

33643342
if (!fRet) {

0 commit comments

Comments
 (0)