Skip to content

Commit 46fa1d6

Browse files
authored
s2: Check input size in pure Go encodes (#244)
1 parent 36a2852 commit 46fa1d6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

s2/encode_go.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ func EncodeSnappy(dst, src []byte) []byte {
3131
// been written.
3232
//
3333
// It also assumes that:
34-
// len(dst) >= MaxEncodedLen(len(src)) &&
35-
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
34+
// len(dst) >= MaxEncodedLen(len(src))
3635
func encodeBlock(dst, src []byte) (d int) {
36+
if len(src) < minNonLiteralBlockSize {
37+
return 0
38+
}
3739
return encodeBlockGo(dst, src)
3840
}
3941

0 commit comments

Comments
 (0)