1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-24 13:48:56 +08:00

Merge pull request #1694 from fivitti/master

Fix panic on OpenBSD and FreeBSD systems if KinfoProc size has an unexpected size
This commit is contained in:
shirou 2024-08-26 23:54:23 +09:00 committed by GitHub
commit 74cb403730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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)