1
0
mirror of https://github.com/golang/go synced 2024-11-17 09:44:48 -07:00

syscall: fix nil pointer dereference in Getdirentries on 32-bit freebsd 12

Don't attempt to dereference basep if it's nil, just pass it to
getdirentries_freebsd12 as is.

Ported from x/sys/unix CL 183223

Change-Id: Id1c4e0eb6ff36dd39524da8194fed9a5957bce61
Reviewed-on: https://go-review.googlesource.com/c/go/+/183797
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser 2019-06-25 14:06:14 +02:00 committed by Tobias Klauser
parent adf888376d
commit 9bf62783d2

View File

@ -267,7 +267,7 @@ func Fstatfs(fd int, st *Statfs_t) (err error) {
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
if supportsABI(_ino64First) {
if unsafe.Sizeof(*basep) == 8 {
if basep == nil || unsafe.Sizeof(*basep) == 8 {
return getdirentries_freebsd12(fd, buf, (*uint64)(unsafe.Pointer(basep)))
}
// The freebsd12 syscall needs a 64-bit base. On 32-bit machines