Limit how much fetch and check read for a manifest or a file (closes #168)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
NewManifestFromReader reads at most one byte past MaxManifestSize, a new constant of 258 MiB: the 256 MiB decompressed limit grown by zstd's worst case of 1/256, plus 1 MiB for the signature, the signing key and the other outer fields. It refuses a larger manifest. fetch, and check given a URL, stop downloading a manifest one byte past the same size and report it as too large; tests lower that size to keep their memory small. fetch stops reading a file one byte past its listed size, so a longer body ends in the size mismatch at once instead of filling the disk. docs/FORMAT.md states the limit and gives the decompressed limit as 256 MiB, the size the code uses. Model: opus-5-5
This commit was merged in pull request #172.
This commit is contained in:
+8
-1
@@ -8,10 +8,17 @@ const (
|
||||
ReleaseDate = "2025-12-17"
|
||||
|
||||
// MaxDecompressedSize is the maximum allowed size of decompressed manifest
|
||||
// data (256 MB). This prevents decompression bombs from consuming excessive
|
||||
// data (256 MiB). This prevents decompression bombs from consuming excessive
|
||||
// memory.
|
||||
MaxDecompressedSize int64 = 256 * 1024 * 1024
|
||||
|
||||
// MaxManifestSize is the largest manifest file mfer reads (258 MiB).
|
||||
// zstd's worst case grows data it cannot compress by 1/256, so an inner
|
||||
// message of MaxDecompressedSize compresses to at most 257 MiB; the
|
||||
// last MiB is room for the signature, the signing key and the other
|
||||
// outer fields.
|
||||
MaxManifestSize = MaxDecompressedSize + MaxDecompressedSize/256 + 1<<20
|
||||
|
||||
// zstdWindowSize is the zstd window zstd.SpeedBestCompression gives mfer's writer.
|
||||
zstdWindowSize = 8 << 20
|
||||
|
||||
|
||||
Reference in New Issue
Block a user