Skip to content

Commit

Permalink
Restore fix for #51, but in a different form
Browse files Browse the repository at this point in the history
The check for end > len(dst) was removed to fix #167, but this caused
a new bug, #189. It's restored in a form that avoids both.

Fixes #189, #191.
  • Loading branch information
greatroar committed Sep 9, 2022
1 parent c3eaa1e commit 118da3a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/lz4block/decode_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ func decodeBlock(dst, src, dict []byte) (ret int) {
mLen += 4
if offset := u16(src[si:]); mLen <= offset && offset < di {
i := di - offset
end := i + 18
copy(dst[di:], dst[i:end])
si += 2
di += mLen
continue
// The remaining buffer may not hold 18 bytes.
// See https://github.com/pierrec/lz4/issues/51.
if end := i + 18; end <= uint(len(dst)) {
copy(dst[di:], dst[i:end])
si += 2
di += mLen
continue
}
}
}
case lLen == 0xF:
Expand Down

0 comments on commit 118da3a

Please sign in to comment.