Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(userspace/libsinsp): stringop-overflow on libvirt_lxc #2115

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions userspace/libsinsp/container_engine/libvirt_lxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@
//
pos = cgroup.find("-lxc\\x2");
if(pos != std::string::npos) {
std::string delimiter = ".scope";
size_t pos2 = cgroup.find(delimiter);
// For cgroups like:
// /machine.slice/machine-lxc\x2d2293906\x2dlibvirt\x2dcontainer.scope/libvirt,
// account for /libvirt below.
if(cgroup.find(".scope/libvirt") != std::string::npos) {
delimiter = ".scope/libvirt";
}
std::string delimiter = (cgroup.find(".scope/libvirt") != std::string::npos)

Check warning on line 48 in userspace/libsinsp/container_engine/libvirt_lxc.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/container_engine/libvirt_lxc.cpp#L48

Added line #L48 was not covered by tests
? ".scope/libvirt"
: ".scope";
size_t pos2 = cgroup.find(delimiter);

Check warning on line 51 in userspace/libsinsp/container_engine/libvirt_lxc.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/container_engine/libvirt_lxc.cpp#L51

Added line #L51 was not covered by tests
if(pos2 != std::string::npos && pos2 == cgroup.length() - delimiter.length()) {
container_info.m_type = CT_LIBVIRT_LXC;
container_info.m_id =
Expand Down
Loading