summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/huff0/decompress.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-22 16:21:19 +0100
committerGitHub <noreply@github.com>2019-11-22 16:21:19 +0100
commite4b805441b84017bdd313d412a4138e4fb41f3d3 (patch)
treebf4088f29a62893822c2696a43f2bebac52d8168 /vendor/github.com/klauspost/compress/huff0/decompress.go
parent22e7d7d86f945620bbc1bdd3aa9c4a9d3248fa1f (diff)
parent866391bb574f885549f5cf3cec965dc224cb84b3 (diff)
downloadpodman-e4b805441b84017bdd313d412a4138e4fb41f3d3.tar.gz
podman-e4b805441b84017bdd313d412a4138e4fb41f3d3.tar.bz2
podman-e4b805441b84017bdd313d412a4138e4fb41f3d3.zip
Merge pull request #4538 from containers/dependabot/go_modules/github.com/containers/storage-1.14.0
build(deps): bump github.com/containers/storage from 1.13.5 to 1.14.0
Diffstat (limited to 'vendor/github.com/klauspost/compress/huff0/decompress.go')
-rw-r--r--vendor/github.com/klauspost/compress/huff0/decompress.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/github.com/klauspost/compress/huff0/decompress.go b/vendor/github.com/klauspost/compress/huff0/decompress.go
index 43b4815b3..7e68a4eb4 100644
--- a/vendor/github.com/klauspost/compress/huff0/decompress.go
+++ b/vendor/github.com/klauspost/compress/huff0/decompress.go
@@ -276,6 +276,7 @@ func (s *Scratch) Decompress4X(in []byte, dstSize int) (out []byte, err error) {
// Use temp table to avoid bound checks/append penalty.
var tmp = s.huffWeight[:256]
var off uint8
+ var decoded int
// Decode 2 values from each decoder/loop.
const bufoff = 256 / 4
@@ -306,6 +307,7 @@ bigloop:
copy(dstOut[dstEvery*3:], tmp[bufoff*3:bufoff*4])
off = 0
dstOut = dstOut[bufoff:]
+ decoded += 256
// There must at least be 3 buffers left.
if len(dstOut) < dstEvery*3 {
return nil, errors.New("corruption detected: stream overrun 2")
@@ -321,9 +323,11 @@ bigloop:
copy(dstOut[dstEvery:dstEvery+ioff], tmp[bufoff:bufoff*2])
copy(dstOut[dstEvery*2:dstEvery*2+ioff], tmp[bufoff*2:bufoff*3])
copy(dstOut[dstEvery*3:dstEvery*3+ioff], tmp[bufoff*3:bufoff*4])
+ decoded += int(off) * 4
dstOut = dstOut[off:]
}
+ // Decode remaining.
for i := range br {
offset := dstEvery * i
br := &br[i]
@@ -335,12 +339,15 @@ bigloop:
dstOut[offset] = decode(br)
offset++
}
+ decoded += offset - dstEvery*i
err = br.close()
if err != nil {
return nil, err
}
}
-
+ if dstSize != decoded {
+ return nil, errors.New("corruption detected: short output block")
+ }
return s.Out, nil
}