Compare commits
1
Commits
0c3b342329
..
next
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2deea2e34 |
+1
-1
@@ -61,7 +61,7 @@ enforce a decompression size limit to prevent decompression bombs. The reference
|
|||||||
implementation limits decompressed size to 256 MiB. It writes zstd frames with a
|
implementation limits decompressed size to 256 MiB. It writes zstd frames with a
|
||||||
window of at most 8 MiB, the largest window the zstd format recommends decoders
|
window of at most 8 MiB, the largest window the zstd format recommends decoders
|
||||||
support, and refuses frames that ask for a larger one. It also refuses an inner
|
support, and refuses frames that ask for a larger one. It also refuses an inner
|
||||||
message whose file entries, hashes and timestamps, counted at 176, 112 and 64
|
message whose file entries, hashes and timestamps, counted at 160, 112 and 64
|
||||||
bytes each, add up to more than 8 times its size. It refuses a manifest file
|
bytes each, add up to more than 8 times its size. It refuses a manifest file
|
||||||
larger than 258 MiB without reading the rest of it: zstd's worst case grows a
|
larger than 258 MiB without reading the rest of it: zstd's worst case grows a
|
||||||
256 MiB inner message by 1/256 to 257 MiB, and the last MiB is room for the
|
256 MiB inner message by 1/256 to 257 MiB, and the last MiB is room for the
|
||||||
|
|||||||
+3
-3
@@ -29,14 +29,14 @@ const (
|
|||||||
// however short its encoding. checkDecodedSize refuses an inner
|
// however short its encoding. checkDecodedSize refuses an inner
|
||||||
// message for which these add up to more than maxDecodedGrowth times
|
// message for which these add up to more than maxDecodedGrowth times
|
||||||
// its size. The mode is held in the file entry itself.
|
// its size. The mode is held in the file entry itself.
|
||||||
decodedFileEntrySize = 176
|
decodedFileEntrySize = 160
|
||||||
decodedHashSize = 112
|
decodedHashSize = 112
|
||||||
decodedTimestampSize = 64
|
decodedTimestampSize = 64
|
||||||
|
|
||||||
// Each file entry mfer writes holds a path of at least one byte, a
|
// Each file entry mfer writes holds a path of at least one byte, a
|
||||||
// multihash at least as long as SHA-256's 34 bytes (AddFileWithHash
|
// multihash at least as long as SHA-256's 34 bytes (AddFileWithHash
|
||||||
// refuses shorter ones) and a modification time: at least 47 bytes,
|
// refuses shorter ones) and a modification time: at least 47 bytes,
|
||||||
// counted at 352. So its manifests add up to at most about 7.49 times
|
// counted at 336. So its manifests add up to at most about 7.15 times
|
||||||
// their size, and this limit is about 7% above that.
|
// their size, and this limit is about 12% above that.
|
||||||
maxDecodedGrowth = 8
|
maxDecodedGrowth = 8
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -296,13 +296,13 @@ func TestDeserializeRefusesModeOutsidePermissionBits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Entries of a path, a SHA-256 hash, an empty second hash and an empty
|
// Entries of a path, a SHA-256 hash, an empty second hash and an empty
|
||||||
// modification time are counted at 464 bytes each (176 + 112 + 112 + 64)
|
// modification time are counted at 448 bytes each (160 + 112 + 112 + 64)
|
||||||
// and take 48 bytes plus the path to encode. A 9-character path makes that
|
// and take 48 bytes plus the path to encode. A 7-character path makes that
|
||||||
// 57 bytes, about 8.1 times: refused, and leaving any one of the four
|
// 55 bytes, about 8.1 times: refused, and leaving any one of the four
|
||||||
// uncounted, even the modification time, brings it under 8. A 10-character
|
// uncounted, even the modification time, brings it under 8. An 8-character
|
||||||
// path makes it 58 bytes, 8 times exactly: loaded. Without the second hash
|
// path makes it 56 bytes, 8 times exactly: loaded. Without the second hash
|
||||||
// an entry is never refused: it takes at least 47 bytes and is counted at
|
// an entry is never refused: it takes at least 47 bytes and is counted at
|
||||||
// 352. There is one entry for each base-36 digit, enough that the 22 bytes
|
// 336. There is one entry for each base-36 digit, enough that the 22 bytes
|
||||||
// of the version and UUID change neither outcome, and each entry's path is
|
// of the version and UUID change neither outcome, and each entry's path is
|
||||||
// its number in base 36, padded with zeros to that length, since a manifest
|
// its number in base 36, padded with zeros to that length, since a manifest
|
||||||
// lists a path only once.
|
// lists a path only once.
|
||||||
@@ -319,8 +319,8 @@ func TestDeserializeRefusesEntriesThatDecodeTooLarge(t *testing.T) {
|
|||||||
pathLen int
|
pathLen int
|
||||||
refused bool
|
refused bool
|
||||||
}{
|
}{
|
||||||
{9, true},
|
{7, true},
|
||||||
{10, false},
|
{8, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user