Add a safety measure for string loading in BGSM

pull/3235/head
Alexei Kotov 4 weeks ago
parent f9f8c1e591
commit 484a360792

@ -41,6 +41,9 @@ namespace Bgsm
std::string BGSMStream::getSizedString(size_t length)
{
// Prevent potential memory allocation freezes; strings this long are not expected in BGSM
if (length > 1024)
throw std::runtime_error("Requested string length is too large: " + std::to_string(length));
std::string str(length, '\0');
mStream->read(str.data(), length);
if (mStream->bad())

Loading…
Cancel
Save