summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/decoder.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-11-19 13:54:45 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2020-11-19 16:09:53 -0500
commit0bad9f1ad799167d869cdb8749b367d3ef664724 (patch)
treef61cb830e24d91b5394b5e87e77369d263ab0a71 /vendor/github.com/klauspost/compress/zstd/decoder.go
parenta18365c908d45a8ee9348c5e32a240a7b9a4091b (diff)
downloadpodman-0bad9f1ad799167d869cdb8749b367d3ef664724.tar.gz
podman-0bad9f1ad799167d869cdb8749b367d3ef664724.tar.bz2
podman-0bad9f1ad799167d869cdb8749b367d3ef664724.zip
vendor in containers/storage v1.24.1 containers/image v5.8.1
These vendors fix the handling of homedirs. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/decoder.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/decoder.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/decoder.go b/vendor/github.com/klauspost/compress/zstd/decoder.go
index d78be6d42..cdda0de58 100644
--- a/vendor/github.com/klauspost/compress/zstd/decoder.go
+++ b/vendor/github.com/klauspost/compress/zstd/decoder.go
@@ -323,19 +323,23 @@ func (d *Decoder) DecodeAll(input, dst []byte) ([]byte, error) {
}
if frame.FrameContentSize > 0 && frame.FrameContentSize < 1<<30 {
// Never preallocate moe than 1 GB up front.
- if uint64(cap(dst)) < frame.FrameContentSize {
+ if cap(dst)-len(dst) < int(frame.FrameContentSize) {
dst2 := make([]byte, len(dst), len(dst)+int(frame.FrameContentSize))
copy(dst2, dst)
dst = dst2
}
}
if cap(dst) == 0 {
- // Allocate window size * 2 by default if nothing is provided and we didn't get frame content size.
- size := frame.WindowSize * 2
+ // Allocate len(input) * 2 by default if nothing is provided
+ // and we didn't get frame content size.
+ size := len(input) * 2
// Cap to 1 MB.
if size > 1<<20 {
size = 1 << 20
}
+ if uint64(size) > d.o.maxDecodedSize {
+ size = int(d.o.maxDecodedSize)
+ }
dst = make([]byte, 0, size)
}