os: do not assume syscall i/o funcs return n=0 on error

Fixes #9007.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/160670043
This commit is contained in:
Russ Cox 2014-10-28 15:00:13 -04:00
parent bd1169dd21
commit a62da2027b
6 changed files with 22 additions and 16 deletions

View file

@ -36,7 +36,7 @@ func (f *File) readdirnames(n int) (names []string, err error) {
if d.bufp >= d.nbuf {
d.bufp = 0
var errno error
d.nbuf, errno = syscall.ReadDirent(f.fd, d.buf)
d.nbuf, errno = fixCount(syscall.ReadDirent(f.fd, d.buf))
if errno != nil {
return names, NewSyscallError("readdirent", errno)
}