]> git.ipfire.org Git - thirdparty/zstd.git/commit
Fix small bug in ZSTD_execSequence() 423/head
authorNick Terrell <terrelln@fb.com>
Thu, 20 Oct 2016 23:45:10 +0000 (16:45 -0700)
committerNick Terrell <terrelln@fb.com>
Fri, 21 Oct 2016 19:13:44 +0000 (12:13 -0700)
commitae1cb3b3d07024618269b89e3421d828adfd34d9
tree80f98fd6b41846d9bd0e6368c928df13b0af6889
parent52c1bf93fe677dc45f243ba05bf7e3a20aa9196c
Fix small bug in ZSTD_execSequence()

`memmove(op, match, sequence.matchLength)` is not the desired behavior.
Overlap is allowed, and handled as if we did `*op++ = *match++`, which
is not how `memmove()` handles overlap.

Only triggered if both of the following conditions are met:
* The match spans extDict & currentPrefixSegment
* `oLitEnd <= oend_w < oLitEnd + length1 < oMatchEnd <= oend`.

These two conditions imply that the block is less than 15 bytes long.
This bug isn't triggered by the streaming API, because it allocates
enough space for the window size + the block size, so there cannot be
a match that is within 8 bytes of the end and overlaps with itself.
It cannot be triggered by the block decompression API because all of
the decompressed data is in the currentPrefixSegment.

Introduced by commit 71585843998459e636f639165ff8a1ca9d161b62
lib/decompress/zstd_decompress.c
lib/legacy/zstd_v04.c
lib/legacy/zstd_v05.c
lib/legacy/zstd_v06.c
lib/legacy/zstd_v07.c