Skip to content

Commit

Permalink
fix(scap): remove the trailing slash when traversing cgroups
Browse files Browse the repository at this point in the history
Without this change, having multiple levels of cgroups nested result on
the path removing the /.. sections, but leaves the prefix locked at the
first slash that is found.

Signed-off-by: Mauro Ezequiel Moltrasio <mmoltras@redhat.com>
  • Loading branch information
Molter73 authored and Andreagit97 committed Sep 21, 2023
1 parent 944716a commit 384665f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions userspace/libscap/linux/scap_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ static int32_t scap_cgroup_prefix_path(const char* prefix, const char* path, siz

while(strncmp(path_p, "/..", 3) == 0)
{
// If there's a trailing slash, remove it before scanning.
if (*prefix_p == '/' && prefix_p != prefix)
{
prefix_p--;
}

path_p += 3;
prefix_p = scan_back(prefix, prefix_p);
if(prefix_p == NULL)
Expand Down

0 comments on commit 384665f

Please sign in to comment.