Skip to content

Commit

Permalink
storage/s3: fixed zero-length range
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalski committed Oct 27, 2018
1 parent 5dbb960 commit 306fa0f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion storage/s3/s3_storage.go
Expand Up @@ -55,10 +55,14 @@ func (s *s3Storage) GetBlock(ctx context.Context, b string, offset, length int64
return nil, err
}

if len(b) != int(length) && length >= 0 {
if len(b) != int(length) && length > 0 {
return nil, fmt.Errorf("invalid length, got %v bytes, but expected %v", len(b), length)
}

if length == 0 {
return []byte{}, nil
}

return b, nil
}

Expand Down

0 comments on commit 306fa0f

Please sign in to comment.