Skip to content

Commit

Permalink
Merge pull request #109 from neicnordic/position_fix
Browse files Browse the repository at this point in the history
Fix bug when seeking in a non-seekable source stream leading to boundary crossings.
  • Loading branch information
aaperis authored Jan 19, 2024
2 parents 8b63ead + a6128d8 commit 9f9735d
Show file tree
Hide file tree
Showing 3 changed files with 979 additions and 850 deletions.
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// The version in the current branch
var Version = "1.8.8"
var Version = "1.8.9"

// If this is "" (empty string) then it means that it is a final release.
// Otherwise, this is a pre-release e.g. "dev", "beta", "rc1", etc.
Expand Down
4 changes: 3 additions & 1 deletion streaming/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func (c *crypt4GHInternalReader) fillBuffer() error {
canRead = skip
}
read, err := c.reader.Read(encryptedSegmentBytes[:canRead])
c.sourcePos += int64(read)

if err != nil {
// Since we're trying to skip forward to our desired block
Expand All @@ -372,6 +373,8 @@ func (c *crypt4GHInternalReader) fillBuffer() error {
// reader should be positioned before the needed segment now

read, err := io.ReadFull(c.reader, encryptedSegmentBytes)
c.sourcePos += int64(read)

if err != nil && err != io.ErrUnexpectedEOF {
return err
}
Expand All @@ -390,7 +393,6 @@ func (c *crypt4GHInternalReader) fillBuffer() error {
return err
}
c.lastDecryptedSegment = neededSegment
c.sourcePos += int64(read)

// Keep track of how much data is directly available

Expand Down
Loading

0 comments on commit 9f9735d

Please sign in to comment.