Skip to content

Commit

Permalink
Merge pull request #1694 from fivitti/master
Browse files Browse the repository at this point in the history
Fix panic on OpenBSD and FreeBSD systems if KinfoProc size has an unexpected size
  • Loading branch information
shirou authored Aug 26, 2024
2 parents 7404c1f + 9772692 commit 74cb403
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 74cb403

Please sign in to comment.