Chore: use unix.ByteSliceToString transform cstring

This commit is contained in:
gVisor bot 2021-06-15 21:03:47 +08:00
parent 225c875ed4
commit 4c477510c3

View file

@ -1,12 +1,13 @@
package process
import (
"bytes"
"encoding/binary"
"net"
"path/filepath"
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
const (
@ -94,12 +95,8 @@ func getExecPathFromPID(pid uint32) (string, error) {
if errno != 0 {
return "", errno
}
firstZero := bytes.IndexByte(buf, 0)
if firstZero <= 0 {
return "", nil
}
return filepath.Base(string(buf[:firstZero])), nil
return filepath.Base(unix.ByteSliceToString(buf)), nil
}
func readNativeUint32(b []byte) uint32 {