From: Rob Pike Date: Wed, 9 Dec 2009 22:18:32 +0000 (-0800) Subject: syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include X-Git-Tag: weekly.2009-12-09~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=51f2932082ecfc7c92aad774be3ebea6436d662b;p=gostls13.git syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include negative counts in return values. R=rsc CC=golang-dev https://golang.org/cl/170044 --- diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go index 03c6d57018..459b78cc22 100644 --- a/src/pkg/os/file.go +++ b/src/pkg/os/file.go @@ -141,11 +141,11 @@ func (file *File) ReadAt(b []byte, off int64) (n int, err Error) { if m == 0 && e == 0 { return n, EOF } - n += m; if e != 0 { err = &PathError{"read", file.name, Errno(e)}; break; } + n += m; b = b[m:]; off += int64(m); } @@ -186,11 +186,11 @@ func (file *File) WriteAt(b []byte, off int64) (n int, err Error) { } for len(b) > 0 { m, e := syscall.Pwrite(file.fd, b, off); - n += m; if e != 0 { err = &PathError{"write", file.name, Errno(e)}; break; } + n += m; b = b[m:]; off += int64(m); }