Skip to content

Commit 94ebcca

Browse files
authored
Merge pull request #43 from nirs/fix-read-zero-cluster
Do not return io.EOF when n == len(p)
2 parents 8255b8a + 1182224 commit 94ebcca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

image/qcow2/qcow2.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,11 @@ func (img *Qcow2) readZero(p []byte, off int64) (int, error) {
944944
func readZero(p []byte, off int64, sz uint64) (int, error) {
945945
var err error
946946
l := len(p)
947-
if uint64(off+int64(l)) >= sz {
947+
// If the n = len(p) bytes returned by ReadAt are at the end of the input
948+
// source, ReadAt may return either err == EOF or err == nil. Returning io.EOF
949+
// seems to confuse io.SectionReader so we return EOF only for out of bound
950+
// request.
951+
if uint64(off+int64(l)) > sz {
948952
l = int(sz - uint64(off))
949953
if l < 0 {
950954
l = 0

0 commit comments

Comments
 (0)