Skip to content

Commit

Permalink
fix: handle invalid KinfoProc size on BSD systems
Browse files Browse the repository at this point in the history
  • Loading branch information
fivitti committed Aug 20, 2024
1 parent e8aa214 commit 9772692
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion process/process_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package process
import (
"bytes"
"context"
"errors"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion process/process_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"io"
"path/filepath"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9772692

Please sign in to comment.