Validate data size for proposals only (#2004)

There are no watchdogs and it makes no sense to limit triggers by size (invalid triggers are going to be voted down anyway).
512 bytes should be more than enough for any proposal - the only value we do not check size of is URL and with 512 bytes total limit URL has space for almost 300 bytes.
This commit is contained in:
UdjinM6 2018-04-05 15:34:26 +03:00 committed by GitHub
parent c0a1099986
commit a0874b72a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -460,13 +460,6 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
return false;
}
// TODO: This is redundant and should be removed
// TODO: Use size validation for each specific object type (if applicable)
if (vchData.size() > MAX_GOVERNANCE_OBJECT_DATA_SIZE) {
strError = strprintf("Invalid object size %d", vchData.size());
return false;
}
switch(nObjectType) {
case GOVERNANCE_OBJECT_WATCHDOG: {
// watchdogs are deprecated

View File

@ -11,6 +11,7 @@
#include <algorithm>
const size_t MAX_DATA_SIZE = 512;
const size_t MAX_NAME_SIZE = 40;
CProposalValidator::CProposalValidator(const std::string& strHexData) :
@ -26,6 +27,10 @@ CProposalValidator::CProposalValidator(const std::string& strHexData) :
void CProposalValidator::ParseStrHexData(const std::string& strHexData)
{
std::vector<unsigned char> v = ParseHex(strHexData);
if (v.size() > MAX_DATA_SIZE) {
strErrorMessages = strprintf("data exceeds %lu characters;", MAX_DATA_SIZE);
return;
}
ParseJSONData(std::string(v.begin(), v.end()));
}