Skip to content

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Ochsenhofer authored and Gabriel Ochsenhofer committed Mar 20, 2019
1 parent f093062 commit ebb2b86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/bspatch/bspatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func patchb(oldfile, patch []byte) ([]byte, error) {

// Read diff string
// lenread, err = dpfbz2.Read(pnew[newpos : newpos+ctrl[0]])
lenread, err = bzreadall(dpfbz2, pnew[newpos:newpos+ctrl[0]], ctrl[0])
lenread, err = zreadall(dpfbz2, pnew[newpos:newpos+ctrl[0]], ctrl[0])
if lenread < ctrl[0] || (err != nil && err != io.EOF) {
e0 := ""
if err != nil {
Expand All @@ -199,8 +199,8 @@ func patchb(oldfile, patch []byte) ([]byte, error) {

// Read extra string
// epfbz2.Read was not reading all the requested bytes, probably an internal buffer limitation ?
// it was encapsulated by bzreadall to work around the issue
lenread, err = bzreadall(epfbz2, pnew[newpos:newpos+ctrl[1]], ctrl[1])
// it was encapsulated by zreadall to work around the issue
lenread, err = zreadall(epfbz2, pnew[newpos:newpos+ctrl[1]], ctrl[1])
if lenread < ctrl[1] || (err != nil && err != io.EOF) {
e0 := ""
if err != nil {
Expand Down Expand Up @@ -258,7 +258,7 @@ func offtin(buf []byte) int {
return y
}

func bzreadall(r io.Reader, b []byte, expected int) (int, error) {
func zreadall(r io.Reader, b []byte, expected int) (int, error) {
var allread int
var offset int
for {
Expand Down
4 changes: 2 additions & 2 deletions pkg/bspatch/bspatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (r *lowcaprdr) Read(b []byte) (int, error) {
return len(b), nil
}

func TestBZReadAll(t *testing.T) {
func TestZReadAll(t *testing.T) {
buf := []byte{
0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20,
0x30, 0x30, 0x30, 0x30, 0x40, 0x40, 0x40, 0x40,
Expand All @@ -275,7 +275,7 @@ func TestBZReadAll(t *testing.T) {
rr := &lowcaprdr{
read: make([]byte, 1024),
}
nr, err := bzreadall(rr, buf, len(buf))
nr, err := zreadall(rr, buf, len(buf))
if err != nil {
t.Fail()
}
Expand Down

0 comments on commit ebb2b86

Please sign in to comment.