From: Tobias Klauser Date: Thu, 1 Mar 2018 08:20:26 +0000 (+0100) Subject: syscall: fix nil pointer dereference in Select on linux/{arm64,mips64x} X-Git-Tag: go1.11beta1~1379 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1023b016d51ee0e6b7245482b9d8715170d785ee;p=gostls13.git syscall: fix nil pointer dereference in Select on linux/{arm64,mips64x} The timeout parameter might be nil, don't dereference it unconditionally. Fixes #24189 Change-Id: I03e6a1ab74fe30322ce6bcfd3d6c42130b6d61be Reviewed-on: https://go-review.googlesource.com/97819 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/syscall/syscall_linux_arm64.go b/src/syscall/syscall_linux_arm64.go index 27c351d7bd..10270cfd00 100644 --- a/src/syscall/syscall_linux_arm64.go +++ b/src/syscall/syscall_linux_arm64.go @@ -74,8 +74,11 @@ type sigset_t struct { //sys pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { - ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} - return pselect(nfd, r, w, e, &ts, nil) + var ts *Timespec + if timeout != nil { + ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} + } + return pselect(nfd, r, w, e, ts, nil) } //sysnb Gettimeofday(tv *Timeval) (err error) diff --git a/src/syscall/syscall_linux_mips64x.go b/src/syscall/syscall_linux_mips64x.go index d9eba62b06..e9bc01f8a0 100644 --- a/src/syscall/syscall_linux_mips64x.go +++ b/src/syscall/syscall_linux_mips64x.go @@ -65,8 +65,11 @@ type sigset_t struct { //sys pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { - ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} - return pselect(nfd, r, w, e, &ts, nil) + var ts *Timespec + if timeout != nil { + ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} + } + return pselect(nfd, r, w, e, ts, nil) } //sysnb Gettimeofday(tv *Timeval) (err error)