mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Add a way to limit deserialized string lengths
and use it for most strings being serialized.
Rebased-From: 216e9a4
This commit is contained in:
committed by
Wladimir J. van der Laan
parent
d78e4312b2
commit
a78996503f
@@ -3408,7 +3408,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
if (!vRecv.empty())
|
||||
vRecv >> addrFrom >> nNonce;
|
||||
if (!vRecv.empty()) {
|
||||
vRecv >> pfrom->strSubVer;
|
||||
vRecv >> LIMITED_STRING(pfrom->strSubVer, 256);
|
||||
pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer);
|
||||
}
|
||||
if (!vRecv.empty())
|
||||
@@ -4005,7 +4005,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
if (fDebug)
|
||||
{
|
||||
string strMsg; unsigned char ccode; string strReason;
|
||||
vRecv >> strMsg >> ccode >> strReason;
|
||||
vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111);
|
||||
|
||||
ostringstream ss;
|
||||
ss << strMsg << " code " << itostr(ccode) << ": " << strReason;
|
||||
@@ -4016,10 +4016,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
vRecv >> hash;
|
||||
ss << ": hash " << hash.ToString();
|
||||
}
|
||||
// Truncate to reasonable length and sanitize before printing:
|
||||
string s = ss.str();
|
||||
if (s.size() > 111) s.erase(111, string::npos);
|
||||
LogPrint("net", "Reject %s\n", SanitizeString(s));
|
||||
LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user