Skip to content

Commit

Permalink
Merge pull request #401 from unphased/too-much-solib-data-read-fix-#317
Browse files Browse the repository at this point in the history
For #317
  • Loading branch information
SimonKagstrom authored Aug 5, 2023
2 parents a013c1c + a527605 commit 93970b2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/solib-handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class SolibHandler : public ISolibHandler, ICollector::IEventTickListener

void solibThreadParse()
{
uint8_t buf[1024 * 1024];
auto buf_ = std::vector<uint8_t>(1024 * 1024 * 100);
uint8_t* buf = buf_.data();

m_solibFd = ::open(m_solibPath.c_str(), O_RDONLY);
m_solibThreadValid = true;
Expand All @@ -149,13 +150,13 @@ class SolibHandler : public ISolibHandler, ICollector::IEventTickListener

while (1)
{
int r = read(m_solibFd, buf, sizeof(buf));
int r = read(m_solibFd, buf, buf_.size());

// The destructor will close m_solibFd, so we'll exit here in that case
if (r <= 0)
break;

panic_if((unsigned )r >= sizeof(buf), "Too much solib data read");
panic_if((unsigned )r >= buf_.size(), "Too much solib data read");

struct phdr_data *p = phdr_data_unmarshal(buf);

Expand Down

0 comments on commit 93970b2

Please sign in to comment.