From 977269202e18f942610819ea6bea486b137d0aae Mon Sep 17 00:00:00 2001 From: Slawek Figiel <4471997+fivitti@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:40:07 +0200 Subject: [PATCH] fix: handle invalid KinfoProc size on BSD systems --- process/process_freebsd.go | 3 ++- process/process_openbsd.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/process/process_freebsd.go b/process/process_freebsd.go index d87c43e8b..436dcf030 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -6,6 +6,7 @@ package process import ( "bytes" "context" + "errors" "path/filepath" "strconv" "strings" @@ -329,7 +330,7 @@ func (p *Process) getKProc() (*KinfoProc, error) { return nil, err } if length != sizeOfKinfoProc { - return nil, err + return nil, errors.New("unexpected size of KinfoProc") } k, err := parseKinfoProc(buf) diff --git a/process/process_openbsd.go b/process/process_openbsd.go index 76ae3e3e0..e2d0ab462 100644 --- a/process/process_openbsd.go +++ b/process/process_openbsd.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "encoding/binary" + "errors" "fmt" "io" "path/filepath" @@ -343,7 +344,7 @@ func (p *Process) getKProc() (*KinfoProc, error) { return nil, err } if length != sizeOfKinfoProc { - return nil, err + return nil, errors.New("unexpected size of KinfoProc") } k, err := parseKinfoProc(buf)