From 5fa412cc5f6801b2b303e4d30404691b5352a3f0 Mon Sep 17 00:00:00 2001 From: shirou Date: Thu, 23 May 2024 09:43:50 +0900 Subject: [PATCH 1/2] [process][freebsd]: add nil check on kInfoProc --- process/process_freebsd.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 40b10e14f..695cabbe0 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -6,6 +6,7 @@ package process import ( "bytes" "context" + "fmt" "path/filepath" "strconv" "strings" @@ -338,5 +339,9 @@ func (p *Process) getKProc() (*KinfoProc, error) { if err != nil { return nil, err } + if &k == nil { + return nil, fmt.Errorf("kInfoProc is nil") + } + return &k, nil } From edb58e3dd10d1fd5d6cc5bf03b1d136d0629b55b Mon Sep 17 00:00:00 2001 From: shirou Date: Thu, 23 May 2024 22:21:59 +0900 Subject: [PATCH 2/2] [process][freebsd]: use binary.Read instead of common.Read --- process/process_bsd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/process_bsd.go b/process/process_bsd.go index 263829ffa..4355455ac 100644 --- a/process/process_bsd.go +++ b/process/process_bsd.go @@ -71,6 +71,6 @@ func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { func parseKinfoProc(buf []byte) (KinfoProc, error) { var k KinfoProc br := bytes.NewReader(buf) - err := common.Read(br, binary.LittleEndian, &k) + err := binary.Read(br, binary.LittleEndian, &k) return k, err }