Skip to content

Commit

Permalink
fix(libsinsp/runc): avoid throwing exception in case of short contain…
Browse files Browse the repository at this point in the history
…er id

Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Jan 6, 2025
1 parent 291d95e commit da108f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion userspace/libsinsp/runc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ bool match_one_container_id(const std::string &cgroup,
return false;
}

container_id = cgroup.substr(start_pos, REPORTED_CONTAINER_ID_LENGTH);
size_t reported_len = end_pos - start_pos >= REPORTED_CONTAINER_ID_LENGTH
? REPORTED_CONTAINER_ID_LENGTH
: end_pos;
container_id = cgroup.substr(start_pos, reported_len);
return true;
}

Expand Down

0 comments on commit da108f6

Please sign in to comment.