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

[CWS] fix panic on empty dirname #10986

Merged
merged 1 commit into from
Feb 18, 2022
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
[CWS] fix panic on empty dirname
  • Loading branch information
paulcacheux authored and lebauce committed Feb 18, 2022
commit 97c289084cc79078eb25bd60c0b5c4b95c5a62a0
6 changes: 5 additions & 1 deletion pkg/security/probe/discarders.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ var (

// use a faster version of path.Dir which adds some sanity checks not required here
func dirname(filename string) string {
if len(filename) == 0 {
return "/"
}

i := len(filename) - 1
for i >= 0 && filename[i] != '/' {
i--
Expand All @@ -225,7 +229,7 @@ func dirname(filename string) string {
return filename
}

if i == 0 {
if i <= 0 {
return "/"
}

Expand Down