mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Fix OOM bug: UTXO entries with invalid script length
This commit is contained in:
parent
4bf631e5e4
commit
5d0434d13d
@ -86,8 +86,14 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nSize -= nSpecialScripts;
|
nSize -= nSpecialScripts;
|
||||||
script.resize(nSize);
|
if (nSize > MAX_SCRIPT_SIZE) {
|
||||||
s >> REF(CFlatData(script));
|
// Overly long script, replace with a short invalid one
|
||||||
|
script << OP_RETURN;
|
||||||
|
s.ignore(nSize);
|
||||||
|
} else {
|
||||||
|
script.resize(nSize);
|
||||||
|
s >> REF(CFlatData(script));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -406,6 +406,20 @@ public:
|
|||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAutoFile& ignore(size_t nSize)
|
||||||
|
{
|
||||||
|
if (!file)
|
||||||
|
throw std::ios_base::failure("CAutoFile::ignore: file handle is NULL");
|
||||||
|
unsigned char data[4096];
|
||||||
|
while (nSize > 0) {
|
||||||
|
size_t nNow = std::min<size_t>(nSize, sizeof(data));
|
||||||
|
if (fread(data, 1, nNow, file) != nNow)
|
||||||
|
throw std::ios_base::failure(feof(file) ? "CAutoFile::ignore: end of file" : "CAutoFile::read: fread failed");
|
||||||
|
nSize -= nNow;
|
||||||
|
}
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
CAutoFile& write(const char* pch, size_t nSize)
|
CAutoFile& write(const char* pch, size_t nSize)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
|
Loading…
Reference in New Issue
Block a user