Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Add sanity check to currentNodeData.Seek
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jan 28, 2019
1 parent 52e19dc commit 343064e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion io/dagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"

ipld "github.com/ipfs/go-ipld-format"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 343064e

Please sign in to comment.