From e2ae339eaf1bbb14108bdd6a32ce8fb8f71144b9 Mon Sep 17 00:00:00 2001 From: shirou Date: Tue, 12 Jul 2022 09:49:23 +0000 Subject: [PATCH] fix(process,linux): remove trailing multiple \x00 --- process/process_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/process/process_linux.go b/process/process_linux.go index df6c1401f..d5b5bc329 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -688,9 +688,9 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string if len(cmdline) == 0 { return nil, nil } - if cmdline[len(cmdline)-1] == 0 { - cmdline = cmdline[:len(cmdline)-1] - } + + cmdline = bytes.TrimRight(cmdline, "\x00") + parts := bytes.Split(cmdline, []byte{0}) var strParts []string for _, p := range parts {