admin_fuzzer: fix too large param to cpu_stats_size setter

Don't pop an empty container, also use stol() so it does not throw
std::out_of_range.

Change-Id: Id81cb00ccfb0ecc234b8f6fa89edf5a0d8c6d353
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92524
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna 2020-04-20 10:26:44 +02:00
parent 6b8456679f
commit 72cfcf7f3e
3 changed files with 6 additions and 1 deletions

View file

@ -238,7 +238,7 @@ void AdminSocketHandler::handleMessage(const std::vector<char> &payload)
}
else if (settingName == "cpu_stats_size")
{
if (settingVal != std::stoi(model.query(settingName)))
if (settingVal != std::stol(model.query(settingName)))
{
model.setCpuStatsSize(settingVal);
}

View file

@ -401,6 +401,11 @@ void AdminModel::setCpuStatsSize(unsigned size)
int wasteValuesLen = _cpuStats.size() - size;
while (wasteValuesLen-- > 0)
{
if (_cpuStats.empty())
{
break;
}
_cpuStats.pop_front();
}
_cpuStatsSize = size;