diff --git a/io/dagreader.go b/io/dagreader.go index 75fb5c714..748bae0f0 100644 --- a/io/dagreader.go +++ b/io/dagreader.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" ipld "github.com/ipfs/go-ipld-format" @@ -426,10 +427,14 @@ func (dr *dagReader) Seek(offset int64, whence int) (int64, error) { return err } - _, err = dr.currentNodeData.Seek(left, io.SeekStart) + n, err := dr.currentNodeData.Seek(left, io.SeekStart) if err != nil { return err } + + if n != left { + return fmt.Errorf("nodeData seeked to wrong position %d, ekpected %d", n, left) + } // The corner case of a DAG consisting only of a single (leaf) // node should make no difference here. In that case, where the // node doesn't have a parent UnixFS node with size hints, this