]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] compress/flate: fix corrupted output
authorKlaus Post <klauspost@gmail.com>
Sat, 17 Oct 2020 15:19:53 +0000 (15:19 +0000)
committerDmitri Shuralyov <dmitshur@golang.org>
Thu, 29 Oct 2020 18:54:36 +0000 (18:54 +0000)
commit777e455106b784b49bf0fe969bcdf802a1104026
treeca9af4a21ffa88f323c94036b65faa9d00b99614
parent8687f6d924ee3a311e08db855c6dc1024c1f9349
[release-branch.go1.15] 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.

Updates #41420.
Fixes #41463.

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>
(cherry picked from commit ab541a0560408999ac65d12bec2a3057994eda38)
Reviewed-on: https://go-review.googlesource.com/c/go/+/266177
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
src/compress/flate/deflate_test.go
src/compress/flate/deflatefast.go