Skip to content

Commit

Permalink
Replaced overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
the-ress committed Oct 7, 2017
1 parent 39fe32b commit f678472
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/agent/Agent.cc
Expand Up @@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -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<DWORD>(processList.size() * 2, processCount);
processList.resize(newSize);
processCount = GetConsoleProcessList(&processList[0], processList.size());
}
Expand Down

0 comments on commit f678472

Please sign in to comment.