Skip to content

Commit

Permalink
Merge pull request #43 from nirs/fix-read-zero-cluster
Browse files Browse the repository at this point in the history
Do not return io.EOF when n == len(p)
  • Loading branch information
AkihiroSuda authored Nov 4, 2024
2 parents 8255b8a + 1182224 commit 94ebcca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion image/qcow2/qcow2.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,11 @@ func (img *Qcow2) readZero(p []byte, off int64) (int, error) {
func readZero(p []byte, off int64, sz uint64) (int, error) {
var err error
l := len(p)
if uint64(off+int64(l)) >= sz {
// If the n = len(p) bytes returned by ReadAt are at the end of the input
// source, ReadAt may return either err == EOF or err == nil. Returning io.EOF
// seems to confuse io.SectionReader so we return EOF only for out of bound
// request.
if uint64(off+int64(l)) > sz {
l = int(sz - uint64(off))
if l < 0 {
l = 0
Expand Down

0 comments on commit 94ebcca

Please sign in to comment.