From f678472b5161222d8f8290ace4725d4d17c040ea Mon Sep 17 00:00:00 2001 From: Tereza Tomcova Date: Sat, 7 Oct 2017 20:33:06 +0200 Subject: [PATCH] Replaced overflow check --- src/agent/Agent.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/agent/Agent.cc b/src/agent/Agent.cc index a6613fb4..a3ab21b9 100644 --- a/src/agent/Agent.cc +++ b/src/agent/Agent.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -439,11 +440,7 @@ void Agent::handleGetConsoleProcessListPacket(ReadBuffer &packet) // The process list can change while we're trying to read it while (processList.size() < processCount) { // Multiplying by two caps the number of iterations - const int newSize = processList.size() * 2; - if (newSize <= processList.size()) { // Ensure we fail when new size overflows - processCount = 0; - break; - } + const auto newSize = std::max(processList.size() * 2, processCount); processList.resize(newSize); processCount = GetConsoleProcessList(&processList[0], processList.size()); }