Skip to content

Commit

Permalink
use new read method everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
gabstv authored and gabstv committed Mar 21, 2019
1 parent ebb2b86 commit d20f7de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/bspatch/bspatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ func patchb(oldfile, patch []byte) ([]byte, error) {
for newpos < newsize {
// Read control data
for i = 0; i <= 2; i++ {
lenread, err = cpfbz2.Read(buf)
lenread, err = zreadall(cpfbz2, buf, 8)
if lenread != 8 || (err != nil && err != io.EOF) {
e0 := ""
if err != nil {
e0 = err.Error()
}
return nil, fmt.Errorf("corrupt patch or bzstream ended: %s", e0)
return nil, fmt.Errorf("corrupt patch or bzstream ended: %s (read: %v/8)", e0, lenread)
}
ctrl[i] = offtin(buf)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/bspatch/bspatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func TestPatch(t *testing.T) {
if !bytes.Equal(newfile, newfilecomp) {
t.Fatal("expected:", newfilecomp, "got:", newfile)
}
// test invalid patch
_, err = Bytes(oldfile, oldfile)
if err == nil {
t.Fail()
}
}

func TestOfftin(t *testing.T) {
Expand Down

0 comments on commit d20f7de

Please sign in to comment.