From 0e13743b7709d523e401c90304f7d7428ca84948 Mon Sep 17 00:00:00 2001 From: eriknordmark Date: Mon, 8 Feb 2021 19:21:22 +0100 Subject: [PATCH] Avoid returning slice into buffer from Readfile Signed-off-by: eriknordmark --- process/process_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/process/process_linux.go b/process/process_linux.go index 669828d..df460dd 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -821,8 +821,12 @@ func (p *Process) fillFromStatusWithContext(ctx context.Context) error { } } } + // Ensure we have a copy and not reference into slice + p.name = string([]byte(p.name)) case "State": p.status = value[0:1] + // Ensure we have a copy and not reference into slice + p.status = string([]byte(p.status)) case "PPid", "Ppid": pval, err := strconv.ParseInt(value, 10, 32) if err != nil {