From 3edde70ef17d23a3f2fcb0fac11a50e8810ab943 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 14 Mar 2025 22:58:10 +0200 Subject: fixed a bug with the filepath --- internal/eventloop.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/eventloop.go') diff --git a/internal/eventloop.go b/internal/eventloop.go index fca5958..1e7fea6 100644 --- a/internal/eventloop.go +++ b/internal/eventloop.go @@ -3,6 +3,7 @@ package internal import "C" import ( + "bytes" "context" "fmt" "os" @@ -178,7 +179,11 @@ func (e *eventLoop) syscallExit(exitEv event.Event, ch chan<- *event.Pair) { openEv := ev.EnterEv.(*OpenEvent) fd := int32(ev.ExitEv.(*RetEvent).Ret) - file := file.NewFd(fd, string(openEv.Filename[:])) + // It's from an array, so only create string from array until first 0 byte + // TODO: This could speed up the path filter as well + // TODO: Hopefully, this won't cause a panic when the filename is as long as the array itself + filePath := string(openEv.Filename[:bytes.IndexByte(openEv.Filename[:], 0)]) + file := file.NewFd(fd, filePath) if fd >= 0 { e.files[fd] = file } -- cgit v1.2.3