]> Cypherpunks.ru repositories - gostls13.git/commit
compress/flate: fix corrupted output
authorKlaus Post <klauspost@gmail.com>
Sat, 17 Oct 2020 15:19:53 +0000 (15:19 +0000)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 19 Oct 2020 18:48:17 +0000 (18:48 +0000)
commitab541a0560408999ac65d12bec2a3057994eda38
tree2c423d6da77e1d5b7355563104787e4ee9ff777d
parent06839e3c9a014da580c2cdcd11263e2b08991b74
compress/flate: fix corrupted output

The fastest compression mode can pick up a false match for every 2GB
of input data resulting in incorrectly decompressed data.

Since matches are allowed to be up to and including at maxMatchOffset
we must offset the buffer by an additional element to prevent the first
4 bytes to match after an out-of-reach value after shiftOffsets has
been called.

We offset by `maxMatchOffset + 1` so offset 0 in the table will now
fail the `if offset > maxMatchOffset` in all cases.

Fixes #41420

Change-Id: If1fbe01728e132b8a207e3f3f439edd832dcc710
GitHub-Last-Rev: 50fabab0da874c37543b139459a810e12e83cee2
GitHub-Pull-Request: golang/go#41477
Reviewed-on: https://go-review.googlesource.com/c/go/+/255879
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
src/compress/flate/deflate_test.go
src/compress/flate/deflatefast.go